답안 #968974

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
968974 2024-04-24T10:33:23 Z CyberCow Inside information (BOI21_servers) C++17
5 / 100
2331 ms 98132 KB
#include <iostream>
using namespace std;

const int N = 4010;
int a[N][N];

void solve()
{
	int n, q, i, j, x, y;
	cin >> n >> q;
	for ( i = 1; i <= n; i++)
	{
		a[i][i] = 1;
	}
	for (int h = 0; h < q + n - 1; h++)
	{
		char c;
		cin >> c;
		if (c == 'S')
		{
			cin >> x >> y;
			for ( i = 1; i <= n; i++)
			{
				a[x][i] = (a[x][i] | a[y][i]);
				a[y][i] = (a[x][i] | a[y][i]);
			}
		}
		else if (c == 'Q')
		{
			cin >> x >> y;
			if (a[x][y])
			{
				cout << "yes\n";
			}
			else
			{
				cout << "no\n";
			}
		}
		else
		{
			cin >> x;
			int ans = 0;
			for ( i = 1; i <= n; i++)
			{
				ans += a[i][x];
			}
			cout << ans << '\n';
		}
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int tt = 1;
	//cin >> tt;
	while (tt--)
	{
		solve();
	}
	return 0;
}

Compilation message

servers.cpp: In function 'void solve()':
servers.cpp:9:15: warning: unused variable 'j' [-Wunused-variable]
    9 |  int n, q, i, j, x, y;
      |               ^
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 3676 KB Output is correct
2 Correct 70 ms 64848 KB Output is correct
3 Correct 51 ms 64852 KB Output is correct
4 Correct 58 ms 64752 KB Output is correct
5 Correct 80 ms 64852 KB Output is correct
6 Correct 78 ms 64848 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 3676 KB Output is correct
2 Correct 70 ms 64848 KB Output is correct
3 Correct 51 ms 64852 KB Output is correct
4 Correct 58 ms 64752 KB Output is correct
5 Correct 80 ms 64852 KB Output is correct
6 Correct 78 ms 64848 KB Output is correct
7 Correct 20 ms 3664 KB Output is correct
8 Correct 2331 ms 64632 KB Output is correct
9 Correct 1924 ms 64716 KB Output is correct
10 Correct 2214 ms 64636 KB Output is correct
11 Correct 2306 ms 64540 KB Output is correct
12 Correct 1722 ms 64584 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 3928 KB Output is correct
2 Runtime error 59 ms 98132 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 3928 KB Output is correct
2 Runtime error 59 ms 98132 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 3688 KB Output is correct
2 Runtime error 67 ms 92024 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 3688 KB Output is correct
2 Runtime error 67 ms 92024 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 3624 KB Output is correct
2 Runtime error 54 ms 88820 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 3624 KB Output is correct
2 Runtime error 54 ms 88820 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 3788 KB Output is correct
2 Runtime error 54 ms 88884 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 3788 KB Output is correct
2 Runtime error 54 ms 88884 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 3688 KB Output is correct
2 Correct 74 ms 64892 KB Output is correct
3 Correct 54 ms 64980 KB Output is correct
4 Correct 70 ms 64864 KB Output is correct
5 Correct 78 ms 64852 KB Output is correct
6 Correct 64 ms 64880 KB Output is correct
7 Correct 15 ms 3676 KB Output is correct
8 Runtime error 56 ms 95020 KB Execution killed with signal 11
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 3688 KB Output is correct
2 Correct 74 ms 64892 KB Output is correct
3 Correct 54 ms 64980 KB Output is correct
4 Correct 70 ms 64864 KB Output is correct
5 Correct 78 ms 64852 KB Output is correct
6 Correct 64 ms 64880 KB Output is correct
7 Correct 15 ms 3676 KB Output is correct
8 Runtime error 56 ms 95020 KB Execution killed with signal 11
9 Halted 0 ms 0 KB -