T1:Weekly Records
模拟
代码实现
n = int(input())
a = list(map(int, input().split()))
ans = [0]*n
for i in range(n):
for j in range(i*7, (i+1)*7):
ans[i] += a[j]
for x in ans:
print(x, end=' ')
T2:racecar
模拟
代码实现
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
bool isPalindrome(string s) {
string t = s;
reverse(t.begin(), t.end());
return s == t;
}
int main() {
int n;
cin >> n;
vector<string> s(n);
rep(i, n) cin >> s[i];
rep(i, n)rep(j, n) {
if (i == j) continue;
string t = s[i]+s[j];
if (isPalindrome(t)) {
puts("Yes");
return 0;
}
}
puts("No");
return 0;
}
T3:Ideal Sheet
暴力枚举两张图的摆放位置即可
代码实现
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
struct Sheet {
int h, w;
vector<string> s;
void input() {
cin >> h >> w;
s = vector<string>(h);
rep(i, h) cin >> s[i];
}
void clear() {
rep(i, h)rep(j, w) s[i][j] = '.';
}
bool copy(Sheet a, int di, int dj) {
rep(i, a.h)rep(j, a.w) {
if (a.s[i][j] == '.') continue;
int ni = i+di, nj = j+dj;
if (ni < 0 or ni >= h or nj < 0 or nj >= w) return false;
s[ni][nj] = a.s[i][j];
}
return true;
}
};
int main() {
Sheet a, b, x;
a.input();
b.input();
x.input();
for (int ai = -a.h; ai < x.h; ++ai) {
for (int aj = -a.w; aj < x.w; ++aj) {
for (int bi = -b.h; bi < x.h; ++bi) {
for (int bj = -b.w; bj < x.w; ++bj) {
Sheet y = x;
y.clear();
if (!y.copy(a, ai, aj)) continue;
if (!y.copy(b, bi, bj)) continue;
if (x.s == y.s) {
puts("Yes");
return 0;
}
}
}
}
}
puts("No");
return 0;
}