답안 #411136

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
411136 2021-05-24T12:15:51 Z blacktulip Inside information (BOI21_servers) C++17
5 / 100
105 ms 49124 KB
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long lo;
typedef pair< lo,lo > PII;
 
#define fi first
#define se second
#define mp make_pair
#define endl "\n"
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)
 
const lo inf = 1000000000000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;
 
int n,m,b[li],a[li],k,flag,t,fa[li],siz[li],son[li],tut[li],num[li],vis[4005][4005],visle[li];
int cev;
string s;
vector<int> v[4005];
 
int main(void){
	scanf("%d %d",&n,&k);
	if(n<=4000){
		FOR{v[i].pb(i);siz[i]=1;}
		k+=n-1;
		while(k--){
			//~ say++;
			char c;
			scanf(" %c",&c);
			if(c=='S'){
				int x,y;
				scanf("%d %d",&x,&y);
				vector<int> vv;
				for(int i=1;i<=n;i++)visle[i]=0;
				for(auto go:v[x]){
					vv.pb(go);
					visle[go]=1;
					siz[go]--;
				}
				for(auto go:v[y]){
					if(visle[go])continue;
					vv.pb(go);
					siz[go]--;
				}
				for(auto go:vv){
					siz[go]+=2;
					vis[x][go]=1;
					vis[y][go]=1;
				}
				v[x]=vv;
				v[y]=vv;
				continue;
			}
			if(c=='Q'){
				int x,y;
				scanf("%d %d",&x,&y);
				if(vis[x][y]){printf("yes\n");}
				else printf("no\n");
				continue;
			}
			int x;
			scanf("%d",&x);
			printf("%d\n",siz[x]);
		}
		return 0;
	}
	FOR{fa[i]=i;siz[i]=1;num[i]=n+1;}
	k+=n-1;
	char c;
	int say=1;
	num[1]=1; 
	while(k--){
		//~ say++;
		scanf(" %c",&c);
		if(c=='S'){
			int x,y;
			scanf("%d %d",&x,&y);
			if(x!=1)num[x]=++say;
			if(y!=1)num[y]=++say;
			continue;
		}
		if(c=='Q'){
			int x,y;
			scanf("%d %d",&x,&y);
			if(num[x]==n+1 || num[y]==n+1){printf("no\n");continue;}
			if(num[x]>=num[y] || x==1 || y==1){printf("yes\n");}
			else printf("no\n");
			continue;
		}
		int x;
		scanf("%d",&x);
		if(num[x]==n+1){printf("1\n");continue;}
		if(x==1){printf("%d\n",say);continue;}
		printf("%d\n",say-num[x]+2);
	}
	return 0;
}

Compilation message

servers.cpp: In function 'int main()':
servers.cpp:32:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |  scanf("%d %d",&n,&k);
      |  ~~~~~^~~~~~~~~~~~~~~
servers.cpp:39:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |    scanf(" %c",&c);
      |    ~~~~~^~~~~~~~~~
servers.cpp:42:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |     scanf("%d %d",&x,&y);
      |     ~~~~~^~~~~~~~~~~~~~~
servers.cpp:66:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   66 |     scanf("%d %d",&x,&y);
      |     ~~~~~^~~~~~~~~~~~~~~
servers.cpp:72:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   72 |    scanf("%d",&x);
      |    ~~~~~^~~~~~~~~
servers.cpp:84:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   84 |   scanf(" %c",&c);
      |   ~~~~~^~~~~~~~~~
servers.cpp:87:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   87 |    scanf("%d %d",&x,&y);
      |    ~~~~~^~~~~~~~~~~~~~~
servers.cpp:94:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   94 |    scanf("%d %d",&x,&y);
      |    ~~~~~^~~~~~~~~~~~~~~
servers.cpp:101:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
  101 |   scanf("%d",&x);
      |   ~~~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 1496 KB Output is correct
2 Incorrect 94 ms 49064 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 1496 KB Output is correct
2 Incorrect 94 ms 49064 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 1484 KB Output is correct
2 Correct 89 ms 5064 KB Output is correct
3 Correct 90 ms 5068 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 1484 KB Output is correct
2 Correct 89 ms 5064 KB Output is correct
3 Correct 90 ms 5068 KB Output is correct
4 Correct 40 ms 1016 KB Output is correct
5 Correct 86 ms 4928 KB Output is correct
6 Correct 77 ms 4124 KB Output is correct
7 Correct 78 ms 4440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 1580 KB Output is correct
2 Incorrect 97 ms 5452 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 1580 KB Output is correct
2 Incorrect 97 ms 5452 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 1444 KB Output is correct
2 Incorrect 86 ms 5384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 1444 KB Output is correct
2 Incorrect 86 ms 5384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 45 ms 1552 KB Output is correct
2 Incorrect 105 ms 5652 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 45 ms 1552 KB Output is correct
2 Incorrect 105 ms 5652 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 1536 KB Output is correct
2 Incorrect 91 ms 49124 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 1536 KB Output is correct
2 Incorrect 91 ms 49124 KB Output isn't correct
3 Halted 0 ms 0 KB -