https://codeforces.com/contest/1750/
新手第二把solved2 rating+254
A
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| #include <bits/stdc++.h> #define endl '\n' #define int long long using namespace std;
void solve() { int n; cin >> n; vector<int> a(n + 1); for (int i = 1; i <= n; i++) { cin >> a[i]; } if (a[1] == 1) cout << "Yes" << endl; else cout << "No" << endl; return; } signed main() { ios::sync_with_stdio(false), cin.tie(nullptr); int _ = 1; cin >> _; while (_--) { solve(); } return 0; }
|
B
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| #include <bits/stdc++.h> #define endl '\n' #define int long long using namespace std;
void solve() { int a; int n; cin >> n; string s; cin >> s; int ans0 = 0, ans1 = 0; int cnt0 = 0, cnt1 = 0; int s0 = 0, s1 = 0; for (auto a : s) { if (a == '0') { ans0++; cnt0++; cnt1 = 0; } else { ans1++; cnt1++; cnt0 = 0; } s0 = max(s0, cnt0); s1 = max(s1, cnt1); } int r1 = ans0 * ans1; int r2 = s0 * s0; int r3 = s1 * s1; cout << max({r1, r2, r3}) << endl; return; }
signed main() { ios::sync_with_stdio(false), cin.tie(nullptr); int _ = 1; cin >> _; while (_--) { solve(); } return 0; }
|
C
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
| #include <bits/stdc++.h> #define endl '\n' #define int long long #define x first #define y second using namespace std;
typedef pair<int, int> PII;
void solve() { int n; cin >> n; string s1, s2; cin >> s1 >> s2; s1 = "?" + s1; s2 = "?" + s2; int cnt = 0; int cnt1 = 0, cnt2 = 0; for (int i = 1; i <= n; i++) { if (s1[i] == s2[i]) { if (s1[i] == '0') cnt1++; else cnt2++; } else cnt++; } if (cnt != 0 && cnt != n) { cout << "NO" << endl; return; } if (cnt1 == n) { cout << "YES" << endl; cout << 0 << endl; return; } if (cnt2 == n) { cout << "YES" << endl; cout << 2 << endl; cout << 1 << " " << 1 << endl; cout << 2 << " " << n << endl; return; }
vector<PII> ans; int cur = 0;
if (cnt) cur++;
for (int i = 1; i <= n; i++) { if (s1[i] == '1') { ans.push_back({i, i}); cur++; } } if (cur % 2 == 1) { ans.push_back({1, 1}); ans.push_back({2, n}); ans.push_back({1, n}); } cout << "YES" << endl; cout << ans.size() << endl; for (auto it : ans) cout << it.first << " " << it.second << endl; } signed main() { ios::sync_with_stdio(false), cin.tie(nullptr); int _ = 1; cin >> _; while (_--) { solve(); } return 0; }
|