赛时脑瘫 + 没仔细读题。脑残把队伍名的 team 去掉了,实际上不一定以 team 开头,怒吃一发罚时。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
voidsolve(){ int n = read(); std::set<std::string> st[26]; for (int i = 1; i <= n; i++) { std::string s, sta; char t; cin >> s >> t >> sta; bool f = (sta == "accepted"); if (f == 0) continue; st[t - 'A'].insert(s); }
int res = 0; for (int i = 0; i < 26; i++) { if (st[i].size() > st[res].size()) res = i; }
cout << char(res + 'A') << '\n'; }
F 单调栈
赛时第一反应竟然都不是单调栈而是 set / 链表。小齐直接化身指针仙人。如果用单调栈写的话应该能少不少罚时吧。
vector<int> a(n + 2); a[0] = a[n + 1] = 2e9; for (int i = 1; i <= n; i++) a[i] = read();
i64 ans = 0;
vector<int> stk {0}; for (int i = 1; i <= n; i++) { while (!stk.empty() and a[stk.back()] < a[i]) { stk.pop_back(); } ans += i - stk.back() - 1; stk.push_back(i); }
stk = {n + 1}; for (int i = n; i >= 1; i--) { while (!stk.empty() and a[stk.back()] < a[i]) { stk.pop_back(); } if (a[stk.back()] != a[i]) ans += stk.back() - i - 1; stk.push_back(i); }
voidsolve(){ int a[32]; for (int i = 0; i < 32; i++) { a[i] = read(); } int cnt = 0; for (int i = 1; i < 32; i++) { if (a[i] < a[0]) { cnt++; } }
int ans = 32; if (cnt >= 31) ans = 1; elseif (cnt >= 27) ans = 2; elseif (cnt >= 13) ans = 4; elseif (cnt >= 6) ans = 8; elseif (cnt >= 2) ans = 16; cout << ans << '\n'; }
voidsolve(){ int n = read(), l = read(), q = read();
vector g(n + 1, std::bitset<2005>()); for (int i = 1; i <= n; i++) g[i][i] = 1;
vector t(l + 1, vector<int>(n + 1)); for (int i = 1; i <= l; i++) { for (int j = 1; j <= n; j++) { t[i][j] = input(); } }
vector<int> ans(q); vector qry(l + 1, vector<std::array<int, 3>>()); for (int i = 0; i < q; i++) { int a = input(), b = input(), c = input(); qry[c].pb({a, b, i}); }
auto add = [&](int a, int b) { if (g[a][b]) return;
for (int i = 1; i <= n; i++) { if (g[i][a]) { g[i] |= g[b]; } } };
auto go = [&](constauto &p) { vector<int> buk(n + 1); int f = 0; for (int i = 1; i <= n; i++) { if (!buk[p[i]]) buk[p[i]] = 1; elseif (f) return; else f = p[i]; }
if (!f) { for (int i = 1; i <= n; i++) { add(i, p[i]); } } else { int x = 0; for (int i = 1; i <= n; i++) { if (!buk[i]) x = i; }
for (int i = 1; i <= n; i++) { if (p[i] == f) { add(i, x); } } } };