답안 #263538

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
263538 2020-08-13T19:02:06 Z T0p_ Experimental Charges (NOI19_charges) C++14
100 / 100
50 ms 3072 KB
#include<bits/stdc++.h>
using namespace std;

int pa[200200];

int fp(int node)
{
	return (node == pa[node]) ? node : pa[node] = fp(pa[node]);
}

int main()
{
	int n, q;
	scanf(" %d %d",&n,&q);
	for(int i=1 ; i<=n+n ; i++)
		pa[i] = i;
	while(q--)
	{
		char c;
		int a, b;
		scanf(" %c %d %d",&c,&a,&b);
		if(c == 'A')
		{
			pa[fp(a)] = fp(b+n);
			pa[fp(a+n)] = fp(b);
		}
		else if(c == 'R')
		{
			pa[fp(a)] = fp(b);
			pa[fp(a+n)] = fp(b+n);
		}
		else
		{
			if(fp(a) == fp(b+n)) printf("A\n");
			else if(fp(a) == fp(b)) printf("R\n");
			else printf("?\n");
		}
	}
	return 0;
}

Compilation message

charges.cpp: In function 'int main()':
charges.cpp:14:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   14 |  scanf(" %d %d",&n,&q);
      |  ~~~~~^~~~~~~~~~~~~~~~
charges.cpp:21:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   21 |   scanf(" %c %d %d",&c,&a,&b);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 2048 KB Output is correct
2 Correct 37 ms 2048 KB Output is correct
3 Correct 41 ms 2040 KB Output is correct
4 Correct 47 ms 2048 KB Output is correct
5 Correct 40 ms 2048 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 42 ms 2552 KB Output is correct
2 Correct 44 ms 2432 KB Output is correct
3 Correct 47 ms 2424 KB Output is correct
4 Correct 45 ms 2432 KB Output is correct
5 Correct 46 ms 2552 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 44 ms 3072 KB Output is correct
2 Correct 45 ms 2756 KB Output is correct
3 Correct 50 ms 2296 KB Output is correct
4 Correct 47 ms 2552 KB Output is correct
5 Correct 43 ms 2424 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 38 ms 2048 KB Output is correct
7 Correct 37 ms 2048 KB Output is correct
8 Correct 41 ms 2040 KB Output is correct
9 Correct 47 ms 2048 KB Output is correct
10 Correct 40 ms 2048 KB Output is correct
11 Correct 42 ms 2552 KB Output is correct
12 Correct 44 ms 2432 KB Output is correct
13 Correct 47 ms 2424 KB Output is correct
14 Correct 45 ms 2432 KB Output is correct
15 Correct 46 ms 2552 KB Output is correct
16 Correct 44 ms 3072 KB Output is correct
17 Correct 45 ms 2756 KB Output is correct
18 Correct 50 ms 2296 KB Output is correct
19 Correct 47 ms 2552 KB Output is correct
20 Correct 43 ms 2424 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 40 ms 2424 KB Output is correct
27 Correct 47 ms 2480 KB Output is correct
28 Correct 43 ms 2424 KB Output is correct
29 Correct 41 ms 2296 KB Output is correct
30 Correct 42 ms 2424 KB Output is correct