Submission #74980

#TimeUsernameProblemLanguageResultExecution timeMemory
74980VardanyanWeighting stones (IZhO11_stones)C++14
100 / 100
113 ms15172 KiB
//#pragma GCC optimize "-O3" #include <bits/stdc++.h> using namespace std; const int N = 100*1000+7; pair<int,int> t[4*N]; int f[4*N]; void push(int v, int s, int e) { if (f[v]) { t[v].first += (1*f[v]); t[v].second += (1*f[v]); if (s != e) { f[v*2] += f[v]; f[v*2 + 1] += f[v]; } f[v] = 0; } } void update(int v, int s, int e, int l, int r, int val) { push(v, s, e); if(l>r) return; if (s == l && e == r) { f[v] += val; push(v, s, e); return; } int m = (s + e) / 2; update(v*2, s, m, l, min(m,r), val); update(v*2 + 1, m + 1, e, max(l,m+1), r, val); push(v*2,s,m); push(v*2+1,m+1,e); t[v].first = max(t[v*2].first, t[v*2 + 1].first); t[v].second = min(t[v*2].second, t[v*2 + 1].second); } int main(){ int n; scanf("%d",&n); for(int i = 1;i<=n;i++){ int r,s; scanf("%d%d",&r,&s); if(s == 1) update(1,1,n,1,r,1); else update(1,1,n,1,r,-1); if(t[1].first>0 && t[1].second<0){ printf("?\n"); continue; } if(t[1].first>=0 && t[1].second>=0){ printf(">\n"); continue; } printf("<\n"); } return 0; }

Compilation message (stderr)

stones.cpp: In function 'int main()':
stones.cpp:38:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
stones.cpp:42:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d",&r,&s);
         ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...