답안 #523442

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
523442 2022-02-07T16:17:05 Z fatemetmhr Inside information (BOI21_servers) C++17
5 / 100
114 ms 41240 KB
// Be name khoda! //
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int maxn5 = 5e3 + 10;
const int lg    = 20;

#define pb    push_back

bool have[maxn5][maxn5];
int ans[maxn5];


int main(){
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	int n, q; cin >> n >> q;
	for(int i = 0; i < n; i++)
		have[i][i] = ans[i] = true;
	for(int i = 0; i < n + q - 1; i++){
		char ty; cin >> ty;
		if(ty == 'S'){
			int a, b; cin >> a >> b;
			a--; b--;
			for(int i = 0; i < n; i++){
				ans[i] += (!have[a][i]) + (!have[b][i]);
				have[a][i] |= have[b][i];
				have[b][i] |= have[a][i];
				ans[i] -= (!have[a][i]) + (!have[b][i]);
			}
		}
		if(ty == 'Q'){
			int a, b; cin >> a >> b;
			a--; b--;
			if(have[a][b])
				cout << "yes\n";
			else
				cout << "no\n";
		}
		if(ty == 'C'){
			int d; cin >> d;
			cout << ans[--d] << '\n';
		}
	}
}











Compilation message

servers.cpp: In function 'int main()':
servers.cpp:22:23: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   22 |   have[i][i] = ans[i] = true;
      |                ~~~~~~~^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 844 KB Output is correct
2 Correct 99 ms 21652 KB Output is correct
3 Correct 79 ms 21680 KB Output is correct
4 Correct 90 ms 21796 KB Output is correct
5 Correct 113 ms 21780 KB Output is correct
6 Correct 114 ms 21688 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 844 KB Output is correct
2 Correct 99 ms 21652 KB Output is correct
3 Correct 79 ms 21680 KB Output is correct
4 Correct 90 ms 21796 KB Output is correct
5 Correct 113 ms 21780 KB Output is correct
6 Correct 114 ms 21688 KB Output is correct
7 Correct 19 ms 1740 KB Output is correct
8 Correct 84 ms 21268 KB Output is correct
9 Correct 74 ms 21440 KB Output is correct
10 Correct 97 ms 21288 KB Output is correct
11 Correct 78 ms 21324 KB Output is correct
12 Correct 77 ms 21440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 860 KB Output is correct
2 Runtime error 36 ms 41240 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 860 KB Output is correct
2 Runtime error 36 ms 41240 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 844 KB Output is correct
2 Runtime error 40 ms 41156 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 844 KB Output is correct
2 Runtime error 40 ms 41156 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 844 KB Output is correct
2 Runtime error 35 ms 41164 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 844 KB Output is correct
2 Runtime error 35 ms 41164 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 836 KB Output is correct
2 Runtime error 39 ms 41156 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 836 KB Output is correct
2 Runtime error 39 ms 41156 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 848 KB Output is correct
2 Correct 96 ms 21664 KB Output is correct
3 Correct 77 ms 21592 KB Output is correct
4 Correct 89 ms 21588 KB Output is correct
5 Correct 90 ms 21644 KB Output is correct
6 Correct 84 ms 21656 KB Output is correct
7 Correct 19 ms 1784 KB Output is correct
8 Runtime error 45 ms 41208 KB Execution killed with signal 11
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 848 KB Output is correct
2 Correct 96 ms 21664 KB Output is correct
3 Correct 77 ms 21592 KB Output is correct
4 Correct 89 ms 21588 KB Output is correct
5 Correct 90 ms 21644 KB Output is correct
6 Correct 84 ms 21656 KB Output is correct
7 Correct 19 ms 1784 KB Output is correct
8 Runtime error 45 ms 41208 KB Execution killed with signal 11
9 Halted 0 ms 0 KB -