Submission #1096323

# Submission time Handle Problem Language Result Execution time Memory
1096323 2024-10-04T09:31:29 Z vjudge1 Inside information (BOI21_servers) C++17
0 / 100
1860 ms 524288 KB
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
const int N=1.2e5+10;
vector<int>rec[N]; 
int main(){
	int n,k,x,y;char s;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i){
		rec[i].push_back(i);
	}
	for(int i=1;i<=n+k-1;++i){
		cin>>s;
		if(s=='S'){
			scanf("%d%d",&x,&y);
			for(int i:rec[x])rec[y].push_back(i);
			for(int i:rec[y])rec[x].push_back(i);
			unique(rec[y].begin(),rec[y].end());
			unique(rec[x].begin(),rec[x].end());
		}else if(s=='Q'){
			scanf("%d%d",&x,&y);
			bool ju=0;
			for(int i:rec[x]){
				if(i==y){
					ju=1;
					printf("yes\n");
					break;
				}
			}
			if(ju==0)printf("no\n");
		}else{
			scanf("%d",&x);
			int cntt=0;
			for(int i=1;i<=n;++i){
				for(int j:rec[i]){
					if(j==x){
						++cntt;
						break;
					}
				}
			}
			printf("%d\n",cntt);
		}
	}
} 

Compilation message

servers.cpp: In function 'int main()':
servers.cpp:10:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |  scanf("%d%d",&n,&k);
      |  ~~~~~^~~~~~~~~~~~~~
servers.cpp:17:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |    scanf("%d%d",&x,&y);
      |    ~~~~~^~~~~~~~~~~~~~
servers.cpp:23:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |    scanf("%d%d",&x,&y);
      |    ~~~~~^~~~~~~~~~~~~~
servers.cpp:34:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |    scanf("%d",&x);
      |    ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 163 ms 3408 KB Output is correct
2 Correct 179 ms 7888 KB Output is correct
3 Runtime error 532 ms 524288 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 163 ms 3408 KB Output is correct
2 Correct 179 ms 7888 KB Output is correct
3 Runtime error 532 ms 524288 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1860 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1860 ms 524288 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 147 ms 3548 KB Output is correct
2 Correct 230 ms 14420 KB Output is correct
3 Correct 226 ms 14420 KB Output is correct
4 Runtime error 511 ms 524288 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 147 ms 3548 KB Output is correct
2 Correct 230 ms 14420 KB Output is correct
3 Correct 226 ms 14420 KB Output is correct
4 Runtime error 511 ms 524288 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 145 ms 3408 KB Output is correct
2 Runtime error 476 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 145 ms 3408 KB Output is correct
2 Runtime error 476 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 144 ms 3408 KB Output is correct
2 Correct 201 ms 14420 KB Output is correct
3 Correct 226 ms 14420 KB Output is correct
4 Runtime error 448 ms 524288 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 144 ms 3408 KB Output is correct
2 Correct 201 ms 14420 KB Output is correct
3 Correct 226 ms 14420 KB Output is correct
4 Runtime error 448 ms 524288 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 149 ms 3536 KB Output is correct
2 Correct 154 ms 7944 KB Output is correct
3 Runtime error 457 ms 524288 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 149 ms 3536 KB Output is correct
2 Correct 154 ms 7944 KB Output is correct
3 Runtime error 457 ms 524288 KB Execution killed with signal 9
4 Halted 0 ms 0 KB -