답안 #1096325

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1096325 2024-10-04T09:32:11 Z vjudge1 Inside information (BOI21_servers) C++14
5 / 100
642 ms 524288 KB
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#define reg register
using namespace std;
const int N=300000;
int n,m,s,l,k,cnt[N];
vector<int>num[N];
vector<int>a;
int main()
{
	scanf("%d%d",&n,&k);
	k+=n-1;
	for(reg int i=1;i<=n;i++)
	{
		num[i].push_back(i);
		cnt[i]=1;
	}
	for(;k;k--)
	{
		char op=getchar();
		while(op!='S'&&op!='Q'&&op!='C')
			op=getchar();
		if(op=='S')
		{
			int x,y;
			scanf("%d%d",&x,&y);
			a=num[y];
			for(auto z:num[x])
			{
				num[y].push_back(z);
				++cnt[z]; 
			}
			for(auto z:a)
			{
				num[x].push_back(z);
				++cnt[z];
			}
		}
		if(op=='Q')
		{
			int x,y;
			scanf("%d%d",&x,&y);
			bool flag=0;
			for(auto z:num[x])
				if(z==y)
				{
					flag=1;
					break; 
				}
			if(flag)
				puts("yes");
			else
				puts("no");
		}
		if(op=='C')
		{
			int x;
			scanf("%d",&x);
			printf("%d\n",cnt[x]); 
		}
	}
}

Compilation message

servers.cpp: In function 'int main()':
servers.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  scanf("%d%d",&n,&k);
      |  ~~~~~^~~~~~~~~~~~~~
servers.cpp:28:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |    scanf("%d%d",&x,&y);
      |    ~~~~~^~~~~~~~~~~~~~
servers.cpp:44:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   44 |    scanf("%d%d",&x,&y);
      |    ~~~~~^~~~~~~~~~~~~~
servers.cpp:60:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   60 |    scanf("%d",&x);
      |    ~~~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 7768 KB Output is correct
2 Correct 21 ms 8028 KB Output is correct
3 Correct 39 ms 14928 KB Output is correct
4 Correct 21 ms 9308 KB Output is correct
5 Correct 24 ms 9308 KB Output is correct
6 Correct 141 ms 59472 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 7768 KB Output is correct
2 Correct 21 ms 8028 KB Output is correct
3 Correct 39 ms 14928 KB Output is correct
4 Correct 21 ms 9308 KB Output is correct
5 Correct 24 ms 9308 KB Output is correct
6 Correct 141 ms 59472 KB Output is correct
7 Correct 14 ms 8536 KB Output is correct
8 Correct 22 ms 9052 KB Output is correct
9 Correct 39 ms 16468 KB Output is correct
10 Correct 25 ms 9044 KB Output is correct
11 Correct 22 ms 8932 KB Output is correct
12 Correct 90 ms 60020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 7768 KB Output is correct
2 Runtime error 642 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 7768 KB Output is correct
2 Runtime error 642 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 7772 KB Output is correct
2 Correct 60 ms 13572 KB Output is correct
3 Correct 104 ms 13704 KB Output is correct
4 Runtime error 482 ms 524288 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 7772 KB Output is correct
2 Correct 60 ms 13572 KB Output is correct
3 Correct 104 ms 13704 KB Output is correct
4 Runtime error 482 ms 524288 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 7768 KB Output is correct
2 Runtime error 553 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 7768 KB Output is correct
2 Runtime error 553 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 7768 KB Output is correct
2 Correct 69 ms 13512 KB Output is correct
3 Correct 64 ms 13580 KB Output is correct
4 Runtime error 441 ms 524288 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 7768 KB Output is correct
2 Correct 69 ms 13512 KB Output is correct
3 Correct 64 ms 13580 KB Output is correct
4 Runtime error 441 ms 524288 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 7772 KB Output is correct
2 Correct 18 ms 8036 KB Output is correct
3 Correct 38 ms 14900 KB Output is correct
4 Correct 19 ms 9308 KB Output is correct
5 Correct 19 ms 9308 KB Output is correct
6 Correct 111 ms 59732 KB Output is correct
7 Correct 15 ms 8536 KB Output is correct
8 Runtime error 575 ms 524288 KB Execution killed with signal 9
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 7772 KB Output is correct
2 Correct 18 ms 8036 KB Output is correct
3 Correct 38 ms 14900 KB Output is correct
4 Correct 19 ms 9308 KB Output is correct
5 Correct 19 ms 9308 KB Output is correct
6 Correct 111 ms 59732 KB Output is correct
7 Correct 15 ms 8536 KB Output is correct
8 Runtime error 575 ms 524288 KB Execution killed with signal 9
9 Halted 0 ms 0 KB -