Submission #787726

# Submission time Handle Problem Language Result Execution time Memory
787726 2023-07-19T11:44:17 Z drkarlicio2107 Inside information (BOI21_servers) C++14
5 / 100
305 ms 524288 KB
#include <bits/stdc++.h>
using namespace std;
int l [5000][5000];
int sz [120010];
bitset <120010> bi [120010];
int main(){
	int n, k; cin >> n >> k;
	if (n<=4000){
		for (int i=1; i<n+1; i++){
			l [i][i]=1; sz [i]=1;
		}
		for (int i=0; i<n+k-1; i++){
			char q; cin >> q;
			if (q=='S'){
				int a, b; cin >> a >> b;
				for (int j=1; j<n+1; j++){
					if (l [a][j]+l [b][j]==1) sz [j]++;
					l [a][j]=l [b][j]=max (l [a][j], l [b][j]);
				}
			}
			else if (q=='Q'){
				int a, b; cin >> a >> b;
				if (l [a][b]==1) cout << "yes" << endl;
				else cout << "no" << endl;
			}
			else {
				int d; cin >> d;
				cout << sz [d] << endl;
			}
		}
	}
	else {
		for (int i=1; i<n+1; i++){
			bi [i][i]=1; sz [i]=1;
		}
		for (int i=0; i<n+k-1; i++){
			char q; cin >> q;
			if (q=='S'){
				int a, b; cin >> a >> b;
				bi [a]|=bi [b];
				bi [b]|=bi [a];
			}
			else if (q=='Q'){
				int a, b; cin >> a >> b;
				if (bi [a][b]==1) cout << "yes" << endl;
				else cout << "no" << endl;
			}
		}
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 161 ms 1668 KB Output is correct
2 Correct 252 ms 80244 KB Output is correct
3 Correct 249 ms 80372 KB Output is correct
4 Correct 296 ms 80296 KB Output is correct
5 Correct 252 ms 80332 KB Output is correct
6 Correct 279 ms 80372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 161 ms 1668 KB Output is correct
2 Correct 252 ms 80244 KB Output is correct
3 Correct 249 ms 80372 KB Output is correct
4 Correct 296 ms 80296 KB Output is correct
5 Correct 252 ms 80332 KB Output is correct
6 Correct 279 ms 80372 KB Output is correct
7 Correct 163 ms 1688 KB Output is correct
8 Correct 237 ms 80024 KB Output is correct
9 Correct 255 ms 80060 KB Output is correct
10 Correct 241 ms 79952 KB Output is correct
11 Correct 231 ms 80004 KB Output is correct
12 Correct 244 ms 80252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 172 ms 1732 KB Output is correct
2 Runtime error 214 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 172 ms 1732 KB Output is correct
2 Runtime error 214 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 163 ms 1724 KB Output is correct
2 Runtime error 157 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 163 ms 1724 KB Output is correct
2 Runtime error 157 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 161 ms 1732 KB Output is correct
2 Runtime error 168 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 161 ms 1732 KB Output is correct
2 Runtime error 168 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 178 ms 1744 KB Output is correct
2 Runtime error 171 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 178 ms 1744 KB Output is correct
2 Runtime error 171 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 165 ms 1752 KB Output is correct
2 Correct 254 ms 80332 KB Output is correct
3 Correct 242 ms 80260 KB Output is correct
4 Correct 271 ms 80296 KB Output is correct
5 Correct 305 ms 80316 KB Output is correct
6 Correct 262 ms 80372 KB Output is correct
7 Correct 170 ms 1712 KB Output is correct
8 Runtime error 170 ms 524288 KB Execution killed with signal 9
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 165 ms 1752 KB Output is correct
2 Correct 254 ms 80332 KB Output is correct
3 Correct 242 ms 80260 KB Output is correct
4 Correct 271 ms 80296 KB Output is correct
5 Correct 305 ms 80316 KB Output is correct
6 Correct 262 ms 80372 KB Output is correct
7 Correct 170 ms 1712 KB Output is correct
8 Runtime error 170 ms 524288 KB Execution killed with signal 9
9 Halted 0 ms 0 KB -