Submission #163557

#TimeUsernameProblemLanguageResultExecution timeMemory
163557SortingRuka (COI15_ruka)C++14
9 / 100
2047 ms3376 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 3e5 + 7; int n, m; array<int, 2> p[MAXN]; array<int, 3> queries[MAXN]; int get_answer(){ int ret = 0; int x = 1, y = 1; for(int i = 0; i < n; ++i){ int newx = x + p[i][0], newy = y + p[i][1]; ret += ((newx > 0) ^ (x > 0)); ret += ((newy > 0) ^ (y > 0)); x = newx, y = newy; } return ret; } void solve(){ int curr_line = 0; for(int i = 0; i < m; ++i){ int type = queries[i][0]; if(type == 'Q'){ cout << get_answer() << "\n"; continue; } if(type == 'B'){ if(curr_line != 0) --curr_line; continue; } if(type == 'F'){ if(curr_line != n - 1) ++curr_line; continue; } //type == 'C' p[curr_line] = {queries[i][1], queries[i][2]}; } } void read(){ ios::sync_with_stdio(false); cin.tie(NULL); cin >> n; for(int i = 0; i < n; ++i){ cin >> p[i][0] >> p[i][1]; } cin >> m; for(int i = 0; i < m; ++i){ char type; cin >> type; queries[i][0] = type; if(type == 'C'){ cin >> queries[i][1] >> queries[i][2]; } } } int main(){ read(); solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...