Submission #725037

# Submission time Handle Problem Language Result Execution time Memory
725037 2023-04-16T13:39:18 Z josanneo22 Inside information (BOI21_servers) C++17
0 / 100
115 ms 196564 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;
}
int maxn=5000;
vector<vector<int>> st(maxn,vector<int>(maxn));
void solve(){
	int n,q; cin>>n>>q;
	vector<int> ti,t(n+5);
	for(int i=1;i<=n;i++){
		t[i]=-1;
	}
	for(int i=0;i<n+q-1;i++){
		char type; cin>>type;
		if(type=='Q'){
			int u,v; cin>>u>>v;
			if(u==v) cout<<"yes\n";
			else if(t[v]==-1 || t[u]==-1) cout<<"no\n";
			else{
				if(u==1 || t[u]>t[v]) cout<<"yes\n";
				else cout<<"no\n";
			}
		}
		else if(type=='S'){
			int u,v; cin>>u>>v;
			if(u>v) swap(u,v);
			t[v]=i;
			ti.push_back(i);
		}
		else{
			int v; cin>>v;
			if(t[v]==-1) cout<<"1\n";
			else{
				int ans=2;
				auto pos=upper_bound(ti.begin(),ti.end(),t[v]);
				int nxt=n-(pos-ti.begin()+1);
				ans+=nxt;
				cout<<ans<<'\n';
			}
		}
	}
}
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 104 ms 196496 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 104 ms 196496 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 113 ms 196564 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 113 ms 196564 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 111 ms 196500 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 111 ms 196500 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 115 ms 196552 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 115 ms 196552 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 110 ms 196540 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 110 ms 196540 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 109 ms 196472 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 109 ms 196472 KB Output isn't correct
2 Halted 0 ms 0 KB -