Submission #598393

#TimeUsernameProblemLanguageResultExecution timeMemory
598393gagik_2007Inside information (BOI21_servers)C++17
0 / 100
272 ms4528 KiB
#include <iostream> #include <algorithm> #include <string> #include <vector> #include <cmath> #include <ctime> #include <set> #include <map> #include <stack> #include <queue> #include <deque> #include <limits> #include <iomanip> #include <unordered_set> #include <unordered_map> #include <random> using namespace std; string findSum(string str1, string str2) { if (str1.length() > str2.length()) swap(str1, str2); string str = ""; int n1 = str1.length(), n2 = str2.length(); reverse(str1.begin(), str1.end()); reverse(str2.begin(), str2.end()); int carry = 0; for (int i = 0; i < n1; i++) { int sum = ((str1[i] - '0') + (str2[i] - '0') + carry); str.push_back(sum % 10 + '0'); carry = sum / 10; } for (int i = n1; i < n2; i++) { int sum = ((str2[i] - '0') + carry); str.push_back(sum % 10 + '0'); carry = sum / 10; } if (carry) str.push_back(carry + '0'); reverse(str.begin(), str.end()); return str; } bool isSmaller(string str1, string str2) { int n1 = str1.length(), n2 = str2.length(); if (n1 < n2) return true; if (n2 < n1) return false; for (int i = 0; i < n1; i++) if (str1[i] < str2[i]) return true; else if (str1[i] > str2[i]) return false; return false; } string findDiff(string str1, string str2) { if (isSmaller(str1, str2)) swap(str1, str2); string str = ""; int n1 = str1.length(), n2 = str2.length(); reverse(str1.begin(), str1.end()); reverse(str2.begin(), str2.end()); int carry = 0; for (int i = 0; i < n2; i++) { int sub = ((str1[i] - '0') - (str2[i] - '0') - carry); if (sub < 0) { sub = sub + 10; carry = 1; } else carry = 0; str.push_back(sub + '0'); } for (int i = n2; i < n1; i++) { int sub = ((str1[i] - '0') - carry); if (sub < 0) { sub = sub + 10; carry = 1; } else carry = 0; str.push_back(sub + '0'); } reverse(str.begin(), str.end()); return str; } typedef long long ll; typedef long double ld; typedef ll itn; #define ff first #define ss second ll ttt; const ll INF = 1e18; const ll MOD = 1e9 + 7; const ll MOD2 = 998244353; const ll MOD3 = 32768; const ll N = 100007; ll n, m, k; ll t[200007]; ll timer = 1; int main() { cin >> n >> k; for (int i = 0; i < n + k - 1; i++) { char typ; cin >> typ; if (typ == 'S') { ll x, y; cin >> x >> y; t[x + y - 1] = timer++; } else if (typ == 'Q') { ll x, y; cin >> x >> y; if (x == 1) { cout << (t[y] ? "yes" : "no") << endl; } else if (y == 1) { cout << (t[x] ? "yes" : "no") << endl; } else if (!t[x] || !t[y] || (t[y] >= t[x])) { cout << "no\n"; } else cout << "yes\n"; } else { ll x; cin >> x; if (x != 1 && !t[x]) { cout << 1 << endl; } else { cout << timer - t[x] + 1 - (x == 1) << endl; } } } } /* 6 9 S 1 2 S 1 3 C 3 C 4 S 1 4 Q 5 1 S 1 5 S 1 6 Q 5 1 Q 1 5 C 1 C 2 C 5 C 6 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...