A
以下题目均用此模板
#include <bits/stdc++.h>
using namespace std;
#define ios \
ios::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
#define mian main
#define pii pair<int, int>
typedef long long ll;
typedef unsigned long long ull;
const int N = 1e6 + 10;
const int mod = 998244353;
int n, m, k, t, q;
ll res, ans, cnt;
void solve()
{
cout << "今天是公历2023年11月30日,再次欢迎大家参加XMIT校赛";
}
int mian()
{
ios;
int _ = 1;
while (_--) {
solve();
}
return 0;
}
B
void solve() {
cin >> n;
while(n--){
int x;
cin >> x;
cout << char(x);
}
}
c
void solve() {
cin >> n >> m;
for(int i = 1 ; i <= n ; i++){
int x;
cin >> x;
k += (m >= x ? x : 0);
}
cout << k;
}
D
void solve() {
cin >> t;
int a, b, c, d;
while (t--) {
scanf("%02d:%02d %02d:%02d", &a, &b, &c, &d);
n = a * 3600 + b * 60;
m = c * 3600 + d * 60;
if (n <= m) {
k = m - n;
} else {
k = 3600 * 24 - n + m;
}
printf("%02dh%02dmin\n", k / 3600, (k % 3600) / 60);
}
}
//ios; 注释掉 ios
E
char mp[N][N];
int vis[N][N];
void dfs(int x, int y) {
int xx[] = {1, 0, -1, 0};
int yy[] = {0, 1, 0, -1};
for (int i = 0; i <= 3; i++) {
int dx = x + xx[i];
int dy = y + yy[i];
if (vis[dx][dy] == 0 && mp[dx][dy] == '*' && dx > 0 && dx <= n && dy > 0 && dy <= m) {
vis[dx][dy] = 1;
dfs(dx, dy);
}
}
}
void solve() {
cin >> n >> m;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
cin >> mp[i][j];
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++)
(mp[i][j] == '*' && vis[i][j] == 0) ? (dfs(i, j), ++cnt) : cnt;
if(cnt) cout << cnt;
else cout << "阳阳学长畅通无阻了";
}
F
map<string, set<int> > mp;
void solve()
{
cin >> t;
string s;
for (int i = 1; i <= t; i++) {
int x;
cin >> x;
while (x--) {
cin >> s;
mp[s].insert(i);
}
}
cin >> t;
while (t--) {
cin >> s;
for (auto i : mp[s]) {
cout << i << ' ';
}
cout << '\n';
}
}
G
int a[N][N], b[N][N];
void solve()
{
int q;
cin >> n >> q;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
cin >> a[i][j], b[i][j] = a[i][j] - a[i - 1][j] - a[i][j - 1] + a[i - 1][j - 1];
}
}
while (q--) {
int l, r, x, y;
cin >> l >> r >> x >> y >> k;
b[l][r] += k;
b[l][y + 1] -= k;
b[x + 1][r] -= k;
b[x + 1][y + 1] += k;
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
b[i][j] += b[i - 1][j] + b[i][j - 1] - b[i - 1][j - 1];
cout << (b[i][j] > 0 ? b[i][j] : 0) << " \n"[j == n];
}
}
}
H
ll a[N] , b[N] , dp[N]; // N = 1e6;
ll s[2][2];
void solve()
{
cin >> n;
for(int i = 1 ; i <= n ; i++)
cin >> a[i];
for(int i = 1 ; i <= n ; i++){
char x;
cin >> x;
if(x == 'B')
b[i] = 1;
else b[i] = 0;
}
for(int i = 1 ; i <= n ; i++){
dp[i] = s[b[i]^1][(a[i]&1)^1] + a[i];
s[b[i]][a[i]&1] = max(s[b[i]][a[i]&1], dp[i]);
ans = max(ans, dp[i]);
}
cout << ans;
}