Submission #673563

# Submission time Handle Problem Language Result Execution time Memory
673563 2022-12-21T05:41:57 Z Baytoro Weighting stones (IZhO11_stones) C++17
100 / 100
60 ms 7500 KB
#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

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 time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 5 ms 1108 KB Output is correct
11 Correct 29 ms 3924 KB Output is correct
12 Correct 60 ms 7284 KB Output is correct
13 Correct 44 ms 7340 KB Output is correct
14 Correct 45 ms 7340 KB Output is correct
15 Correct 43 ms 7424 KB Output is correct
16 Correct 45 ms 7384 KB Output is correct
17 Correct 43 ms 7372 KB Output is correct
18 Correct 40 ms 7420 KB Output is correct
19 Correct 40 ms 7432 KB Output is correct
20 Correct 38 ms 7372 KB Output is correct
21 Correct 39 ms 7500 KB Output is correct
22 Correct 47 ms 7436 KB Output is correct
23 Correct 43 ms 7424 KB Output is correct
24 Correct 40 ms 7328 KB Output is correct
25 Correct 39 ms 7364 KB Output is correct