Testing Round #16 (Unrated)
比赛链接:https://codeforces.com/contest/1351
A - A+B (Trial Problem)
#include <bits/stdc++.h> using namespace std; void solve() { int a, b; cin >> a >> b; cout << a + b << "\n"; } int main() { int t; cin >> t; while (t--) solve(); }
B - Square?
#include <bits/stdc++.h> using namespace std; void solve() { int a1, b1, a2, b2; cin >> a1 >> b1 >> a2 >> b2; if (a1 > b1) swap(a1, b1); if (a2 > b2) swap(a2, b2); if (a1 + a2 == b1 and b1 == b2) cout << "YES" << "\n"; else cout << "NO" << "\n"; } int main() { int t; cin >> t; while (t--) solve(); }
C - Skier
#include <bits/stdc++.h> using namespace std; void solve() { string s; cin >> s; map<pair<pair<int, int>, pair<int, int>>, bool> mp; pair<int, int> pr{0, 0}; int ans = 0; for (char c : s) { pair<int, int> pr0 = pr; if (c == 'N') pr.second++; else if (c == 'S') pr.second--; else if (c == 'W') pr.first--; else pr.first++; pair<pair<int, int>, pair<int, int>> p1 = make_pair(pr0, pr); pair<pair<int, int>, pair<int, int>> p2 = make_pair(pr, pr0); if (mp[p1] or mp[p2]) ++ans; else mp[p1] = mp[p2] = true, ans += 5; } cout << ans << "\n"; } int main() { int t; cin >> t; while (t--) solve(); }
我这也算是在线 ak 过一场 cf 了吧 =。=