Submission #673563

#TimeUsernameProblemLanguageResultExecution timeMemory
673563BaytoroWeighting stones (IZhO11_stones)C++17
100 / 100
60 ms7500 KiB
#include <bits/stdc++.h> using namespace std; #define ios ios::sync_with_stdio(false); cin.tie(NULL); #define pb push_back #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define fr first #define sc second #define int long long #define endl '\n' void fopn(string name){ freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout); } const int INF=1e18,mod=998244353; int n; const int N=1e5+5; int mn[4*N],mx[4*N],lazy[4*N]; void push(int l, int r, int x){ if(lazy[x]){ mn[x]+=lazy[x]; mx[x]+=lazy[x]; if(l!=r){ lazy[2*x]+=lazy[x]; lazy[2*x+1]+=lazy[x]; } lazy[x]=0; } } void update(int lx, int rx, int v, int x=1,int l=1, int r=n){ push(l,r,x); if(l>rx || r<lx) return; if(lx<=l && r<=rx){ lazy[x]+=v; push(l,r,x); return; } int md=(l+r)/2; update(lx,rx,v,2*x,l,md); update(lx,rx,v,2*x+1,md+1,r); mx[x]=max(mx[2*x],mx[2*x+1]); mn[x]=min(mn[2*x],mn[2*x+1]); } void solve(){ cin>>n; for(int i=0;i<n;i++){ int t,x; cin>>t>>x; int k=1; if(x==2) k=-1; update(1,t,k); if(mx[1]>0 && mn[1]>=0){ cout<<">\n"; } else if(mx[1]<=0 && mn[1]<0){ cout<<"<\n"; } else cout<<"?\n"; } } main(){ //fopn("newbarn"); ios; int T=1; //cin>>T; while(T--){ solve(); } }

Compilation message (stderr)

stones.cpp:62:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   62 | main(){
      | ^~~~
stones.cpp: In function 'void fopn(std::string)':
stones.cpp:12:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |  freopen((name+".in").c_str(),"r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
stones.cpp:13:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  freopen((name+".out").c_str(),"w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...