Submission #883385

#TimeUsernameProblemLanguageResultExecution timeMemory
883385vjudge1Ruka (COI15_ruka)C++17
9 / 100
2033 ms852 KiB
#include <bits/stdc++.h> #define fi first #define se second using namespace std; const int N = 1e5+7; int n, q; pair<int, int> a[N]; int solve() { int res=0; int x=1, y=1; bool c1=true, c2=true; for(int i=1; i<=n; i++) { x+=a[i].fi, y+=a[i].se; if((c1&&x<0)||(!c1&&x>0)) { res++; c1^=1; } if((c2&&y<0)||(!c2&&y>0)) { res++; c2^=1; } } return res; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n; for(int i=1; i<=n; i++) cin>>a[i].fi>>a[i].se; cin>>q; a[0]={1, 1}; int pos=1; while(q--) { char t; cin>>t; if(t=='B') pos=max(1, pos-1); if(t=='F') pos=min(n, pos+1); if(t=='C') { int x, y; cin>>x>>y; a[pos]= {x, y}; } if(t=='Q') cout<<solve()<<"\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...