Submission #337780

#TimeUsernameProblemLanguageResultExecution timeMemory
337780beksultan04Weighting stones (IZhO11_stones)C++14
100 / 100
76 ms7020 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define pii pair<int,int> #define OK puts("OK"); #define NO puts("NO"); #define YES puts("YES"); #define fr first #define sc second #define ret return #define scan1(a) scanf("%lld",&a); #define scan2(a,b) scanf("%lld %lld",&a, &b); #define scan3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c); #define all(s) s.begin(),s.end() #define allr(s) s.rbegin(),s.rend() #define pb push_back #define sz(v) (int)v.size() #define endi puts(""); const int N = 1e6+12,INF=1e9+7; int pus[N]; pii der[N]; void push(int v,int l,int r){ der[v].fr += pus[v]; der[v].sc += pus[v]; if (l != r){ pus[v<<1]+=pus[v]; pus[(v<<1)+1]+=pus[v]; } pus[v]=0; } void update(int v,int l,int r,int ql,int qr,int x){ push(v,l,r); if (ql > r || l > qr)ret ; if (ql <= l && r <= qr){ pus[v]+=x; push(v,l,r); ret ; } int m = (l+r)>>1; update(v<<1,l,m,ql,qr,x); update((v<<1)+1,m+1,r,ql,qr,x); der[v].fr = min(der[v<<1].fr,der[(v<<1)+1].fr); der[v].sc = max(der[v<<1].sc,der[(v<<1)+1].sc); } main(){ int n,i; scan1(n) i=n; while (i--){ int a,b; scan2(a,b) if (b == 1){ update(1,1,n,1,a,-1); } else { update(1,1,n,1,a,1); } if (der[1].fr >= 0){ cout <<"<\n"; } else if (der[1].sc <= 0){ cout <<">\n"; } else cout <<"?\n"; } }

Compilation message (stderr)

stones.cpp:48:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   48 | main(){
      |      ^
stones.cpp: In function 'int main()':
stones.cpp:11:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   11 | #define scan1(a) scanf("%lld",&a);
      |                  ~~~~~^~~~~~~~~~~
stones.cpp:50:5: note: in expansion of macro 'scan1'
   50 |     scan1(n)
      |     ^~~~~
stones.cpp:12:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   12 | #define scan2(a,b) scanf("%lld %lld",&a, &b);
      |                    ~~~~~^~~~~~~~~~~~~~~~~~~~
stones.cpp:54:9: note: in expansion of macro 'scan2'
   54 |         scan2(a,b)
      |         ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...