Submission #724970

# Submission time Handle Problem Language Result Execution time Memory
724970 2023-04-16T11:58:44 Z josanneo22 Inside information (BOI21_servers) C++17
0 / 100
28 ms 1760 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
inline int rd(){
	int x=0,w=1;
	char ch=getchar();
	for(;ch>'9'||ch<'0';ch=getchar()) if(ch=='-') w=-1;
	for(;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x*w;
}
void solve(){
	int n,q; cin>>n>>q;
	vector<int> pre(n+q+2),t(n+2);
	t[1]=0;
	for(int i=0;i<n+q-1;i++){
		char x; cin>>x;
		if(x=='C'){
			int block; cin>>block;
			int ti=t[block];
			//how many blocks that has S after ti
			if(ti==-1) cout<<"1\n"; 
			else{
				int ans=pre[i-1]+(ti-1>=0?pre[ti-1]:0)+1;
				cout<<ans<<'\n';
			}
		}
		else if(x=='Q'){
			int u,v; cin>>u>>v;
			int tv=t[v],tu=t[u];
			if(tu<=tv) cout<<"yes\n";
			else cout<<"no\n";
		}
		else{
			int u,v; cin>>u>>v;
			if(u>v) swap(u,v);
			t[v]=i;
			pre[i]=1;
		}
		if(i>0) pre[i]=pre[i-1]+pre[i];
	}
}
signed main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int tt=1; //cin>>tt;
	while(tt--){
		solve();
	}
}
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 1620 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 1620 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 28 ms 1612 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 28 ms 1612 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 1624 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 1624 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 1684 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 1684 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 1620 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 1620 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 1760 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 1760 KB Output isn't correct
2 Halted 0 ms 0 KB -