Submission #883414

#TimeUsernameProblemLanguageResultExecution timeMemory
883414VN_AnhTuanRuka (COI15_ruka)C++17
9 / 100
2074 ms6792 KiB
// Author : Nguyen Anh Tuan - THPT Chuyen Bac Giang - Train VOI 2023/2024 #include<bits/stdc++.h> #define file(NAME) {freopen(NAME".inp", "r", stdin); freopen(NAME".out", "w", stdout);} #define foru(i, a, b) for(int i=(a);i<=(b);i++) #define ford(i, a, b) for(int i=(a);i>=(b);i--) #define rep(i, n) for(int i=(1);i<=(n);i++) #define fi first #define se second #define mp make_pair #define SZ(v) ((int)((v).size())) #define all(v) v.begin(),v.end() #define RR(X) X.resize(unique(all(X)) - begin(X)) using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; using pii = pair<int, int>; namespace IO { #define getchar() (ipos==iend and (iend=(ipos=_ibuf)+fread(_ibuf,1,__bufsize,stdin),ipos==iend)?EOF:*ipos++) #define putchar(ch) (opos==oend?fwrite(_obuf,1,__bufsize,stdout),opos=_obuf:0,*opos++=(ch)) #define __bufsize (1<<20) char _ibuf[__bufsize],_obuf[__bufsize],_stk[20]; char *ipos=_ibuf,*iend=_ibuf,*opos=_obuf,*oend = _obuf+__bufsize,*stkpos = _stk; struct END{~END(){fwrite(_obuf,1,opos-_obuf,stdout);}}__; inline void read(int &x) { register ll f=0,ch; for(;!isdigit(ch);ch=getchar())if(ch=='-')f=1; for(x=0;isdigit(ch);ch=getchar())x=(x<<3ll)+(x<<1ll)+(ch^48); x=f?-x:x; } inline void write(int x) { if(x<0)putchar('-'),x=-x; while(*++stkpos=x%10^48,x/=10,x); while(stkpos!=_stk)putchar(*stkpos--); } inline void lread(ll&x) { register ll f=0,ch; for(;!isdigit(ch);ch=getchar())if(ch=='-')f=1; for(x=0;isdigit(ch);ch=getchar())x=(x<<3ll)+(x<<1ll)+(ch^48); x=f?-x:x; } inline void lwrite(ll x) { if(x<0)putchar('-'),x=-x; while(*++stkpos=x%10^48,x/=10,x); while(stkpos!=_stk)putchar(*stkpos--); } }; void maximum(ll &a, ll b) {if(b > a) a = b;} void minimum(ll &a, ll b) {if(b < a) a = b;} bool bit(int x, int i) {return (x >> i) & 1;} //----------------------------------------------------------------------------------- // END OF TEMPLATE //----------------------------------------------------------------------------------- // Nguyen Anh Tuan - AnhTuan_BG // PRAY FOR VOI 2023 //----------------------------------------------------------------------------------- const int maxn = 300005; int n, q; pii a[maxn]; struct type { char c; int x, y; } ques[maxn]; namespace sub1 { int cnt(pii a, pii b) { int ans = 0; if((a.fi > 0 && b.fi < 0) || (a.fi < 0 && b.fi > 0)) ans++; if((a.se > 0 && b.se < 0) || (a.se < 0 && b.se > 0)) ans++; return ans; } int Calc() { int ans = 0; pii Point = mp(1, 1); foru(i, 1, n) { pii newPoint = mp(Point.fi + a[i].fi, Point.se + a[i].se); ans = ans + cnt(Point, newPoint); Point = newPoint; } return ans; } void solve() { int idx = 1; foru(i, 1, q) { auto [c, x, y] = ques[i]; if(c == 'B') idx = idx - (idx > 1); if(c == 'F') idx = idx + (idx < n); if(c == 'C') a[idx] = mp(x, y); if(c == 'Q') cout << Calc() << "\n"; } } } int main() { ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0); //file(""); cin >> n; foru(i, 1, n) cin >> a[i].fi >> a[i].se; cin >> q; foru(i, 1, q) { cin >> ques[i].c; if(ques[i].c == 'C') cin >> ques[i].x >> ques[i].y; } sub1 :: solve(); return 0; }

Compilation message (stderr)

ruka.cpp: In function 'void IO::read(int&)':
ruka.cpp:31:21: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   31 |         register ll f=0,ch;
      |                     ^
ruka.cpp:31:25: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   31 |         register ll f=0,ch;
      |                         ^~
ruka.cpp: In function 'void IO::lread(ll&)':
ruka.cpp:44:21: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   44 |         register ll f=0,ch;
      |                     ^
ruka.cpp:44:25: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   44 |         register ll f=0,ch;
      |                         ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...