Submission #725032

# Submission time Handle Problem Language Result Execution time Memory
725032 2023-04-16T13:29:19 Z josanneo22 Inside information (BOI21_servers) C++17
5 / 100
2860 ms 398200 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;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			st[i][j]=0;
		}
	}
	for(int i=1;i<=n;i++){
		st[i][i]=1;
	}
	for(int i=0;i<n+q-1;i++){
		char x; cin>>x;
		if(x=='C'){
			int v; cin>>v;
			int cnt=0;
			for(int j=1;j<=n;j++){
				if(st[j][v]==1) cnt++;
			}
			cout<<cnt<<'\n';
		}
		else if(x=='Q'){
			int u,v; cin>>u>>v;
			if(st[u][v]) cout<<"yes\n";
			else cout<<"no\n";
		}
		else{
			int u,v; cin>>u>>v;
			for(int k=1;k<=n;k++){
				if(st[u][k] || st[v][k]) st[v][k]=1,st[u][k]=1;
			}
		}
	}
}
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 Correct 99 ms 196572 KB Output is correct
2 Correct 166 ms 196844 KB Output is correct
3 Correct 201 ms 196812 KB Output is correct
4 Correct 169 ms 196776 KB Output is correct
5 Correct 160 ms 196812 KB Output is correct
6 Correct 267 ms 196840 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 99 ms 196572 KB Output is correct
2 Correct 166 ms 196844 KB Output is correct
3 Correct 201 ms 196812 KB Output is correct
4 Correct 169 ms 196776 KB Output is correct
5 Correct 160 ms 196812 KB Output is correct
6 Correct 267 ms 196840 KB Output is correct
7 Correct 100 ms 196752 KB Output is correct
8 Correct 2743 ms 196768 KB Output is correct
9 Correct 2460 ms 197700 KB Output is correct
10 Correct 2860 ms 197548 KB Output is correct
11 Correct 2689 ms 197564 KB Output is correct
12 Correct 2484 ms 197956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 107 ms 196568 KB Output is correct
2 Runtime error 498 ms 398200 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 107 ms 196568 KB Output is correct
2 Runtime error 498 ms 398200 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 107 ms 196556 KB Output is correct
2 Runtime error 549 ms 398184 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 107 ms 196556 KB Output is correct
2 Runtime error 549 ms 398184 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 107 ms 196476 KB Output is correct
2 Runtime error 516 ms 398196 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 107 ms 196476 KB Output is correct
2 Runtime error 516 ms 398196 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 124 ms 196792 KB Output is correct
2 Runtime error 581 ms 398120 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 124 ms 196792 KB Output is correct
2 Runtime error 581 ms 398120 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 125 ms 196744 KB Output is correct
2 Correct 172 ms 197088 KB Output is correct
3 Correct 185 ms 197104 KB Output is correct
4 Correct 169 ms 197028 KB Output is correct
5 Correct 176 ms 197064 KB Output is correct
6 Correct 250 ms 197136 KB Output is correct
7 Correct 103 ms 197068 KB Output is correct
8 Runtime error 483 ms 398172 KB Execution killed with signal 11
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 125 ms 196744 KB Output is correct
2 Correct 172 ms 197088 KB Output is correct
3 Correct 185 ms 197104 KB Output is correct
4 Correct 169 ms 197028 KB Output is correct
5 Correct 176 ms 197064 KB Output is correct
6 Correct 250 ms 197136 KB Output is correct
7 Correct 103 ms 197068 KB Output is correct
8 Runtime error 483 ms 398172 KB Execution killed with signal 11
9 Halted 0 ms 0 KB -