毫无难度啊。
A - Trick Taking
硬模拟就行。
cpp
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int n, t, c[maxn], r[maxn];
signed main(){
cin >> n >> t;
bool flag = 0;
for(int i = 1; i <= n; i++) {
cin >> c[i];
if(c[i] == t) flag = 1;
}
int maxx1 = 0, maxx2 = 0, pos1 = -1, pos2 = -1;
for(int i = 1; i <= n; i++) {
cin >> r[i];
if(c[i] == t && maxx1 < r[i]) maxx1 = r[i], pos1 = i;
if(c[i] == c[1] && maxx2 < r[i]) maxx2 = r[i], pos2 = i;
}
cout << (flag ? pos1 : pos2);
return 0;
}
B - Same Map in the RPG World
数据范围很小,可以直接枚举(s, t)的所有组合,判断即可。
当然码力弱的人未必能写。
cpp
#include<bits/stdc++.h>
using namespace std;
int n, m;
char a[35][35], b[35][35];
bool check(int s, int t) {
bool flag = 1;
for(int i = 1, j = s; i <= n; i++, j++) {
if(j > n) j = 1;
for(int k = t, h = 1; h <= m; k++, h++) {
if(k > m) k = 1;
if(a[i][h] != b[j][k]) {
flag = 0;
break;
}
}
if(!flag) break;
}
return flag;
}
signed main(){
cin >> n >> m;
for(int i = 1; i <= n; i++)
for(int j = 1; j <= m; j++)
cin >> a[i][j];
for(int i = 1; i <= n; i++)
for(int j = 1; j <= m; j++)
cin >> b[i][j];
for(int i = 1; i <= n; i++)
for(int j = 1; j <= m; j++)
if(check(i, j)) {
cout << "Yes";
return 0;
}
cout << "No";
return 0;
}
C - Cross
直接枚举各个长度的十字架就完事了。
这场看起来相当暴力。
cpp
# include <bits/stdc++.h>
using namespace std;
const int maxn = 110;
char c[maxn][maxn];
int n, m, ans[maxn];
int d[][2] = {{-1, -1}, {-1, 1}, {1, 1}, {1, -1}};
int check(int x, int y) {
int ret = 0, t = 1;
while(1) {
for(int i = 0; i < 4; i++) {
int dx = x + d[i][0] * t, dy = y + d[i][1] * t;
if(dx < 1 || dx > n || dy < 1 || dy > m) return ret;
if(c[dx][dy] == '.') return ret;
}
ret = t;
t++;
}
}
signed main() {
cin >> n >> m;
for(int i = 1; i <= n; i++)
for(int j = 1; j <= m; j++)
cin >> c[i][j];
for(int i = 1; i <= n; i++)
for(int j = 0; j < m; j++)
if(c[i][j] == '#')
ans[check(i, j)]++;
for(int i = 1; i <= min(n, m); i++) cout << ans[i] << " ";
return 0;
}
D - Cards Query Problem
典型的STL题:
对于操作1和操作2,我们可以开个vector数组,那么把数组 i i i 放入 j j j 实际上就可以用v[j].push_back(i)来搞定,输出同理,排个序就完事了。
对于操作3来说有排序和去重操作,所以我们可以用set维护。
cpp
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int n, m;
vector<int> v[maxn];
set<int> s[maxn];
int main() {
cin >> n >> m;
for(int i = 0; i < m; i++) {
int opt, x; cin >> opt >> x;
if(opt == 1) {
int y; cin >> y;
v[y].push_back(x), s[x].insert(y);
}
else if(opt == 2) {
sort(v[x].begin(), v[x].end());
for(auto val : v[x]) cout << val << " ";
cout << endl;
}
else {
for(auto val : s[x]) cout << val << " ";
cout << endl;
}
}
return 0;
}
E - Coloring Matrix
转4次不就完事了。跟温州市赛那题毫无区别,这题甚至还给了旋转公式,代码就不放了。