36:18 AC:3,WA:1,CE:0,RE:2
レート変化:+1 657
久々の日曜日開催でした。
1:10 AC
vectorの奇数番目の要素を出力します。
#includeusing namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int a; cin >> a; vector b(a); int cnt = 0; for (int i = 0; i < a; i++) { cin >> b[i]; if (i % 2 == 0) { cnt += b[i]; } } cout << cnt << endl; return 0; }
16:39 AC
Tを全探索すればよいです
#includeusing namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); string s; cin >> s; string n; cin >> n; int cnt = 0; for (int i = 0; i < s.size() - n.size() + 1; i++) { cnt = 0; for (int j = 0; j < n.size(); j++) { if (s[i + j] == n[j] || s[i + j] == '?') { cnt++; } if (cnt == n.size()) { cout << "Yes" << endl; return 0; } } } cout << "No" << endl; }
26:18 AC RE:2
ユーザーとコンテストのmapを作ります。
また、query2のユーザーは別に管理します
#includeusing namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); int n, m, q; cin >> n >> m >> q; vector > permissions(n); vector allAccess(n, false); int query, x, y; for (int i = 0; i < q; i++) { cin >> query; if (query == 1) { cin >> x >> y; permissions[x - 1].insert(y); } else if (query == 2) { cin >> x; allAccess[x - 1] = true; } else if (query == 3) { cin >> x >> y; if (allAccess[x - 1] || permissions[x - 1].count(y)) { cout << "Yes\n"; } else { cout << "No\n"; } } } return 0; }
Cの要素外アクセスでのREはなくしたかったです。
Bの全探索にも時間がかかりすぎました
15分で解き終わりたかったです。
2025/04/27