답안 #72538

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
72538 2018-08-26T08:53:48 Z 마릴린 희정(#2180, gs14004, ho94949) 초코쿠키 기계 (FXCUP3_chocolate) C++17
100 / 100
1206 ms 32280 KB
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 300005;

int n, m, k, chk[MAXN];
vector<int> gph[MAXN];
int stat[MAXN], mp[MAXN];

int main(){
	scanf("%d %d %d",&n,&m,&k);
	for(int i=0; i<m; i++){
		int x;
		scanf("%d",&x);
		chk[x] = 1;
	}
	for(int i=0; i<k; i++){
		int s, e;
		scanf("%d %d",&s,&e);
		gph[s].push_back(e);
		gph[e].push_back(s);
	}
	scanf("%d",&m);
	char sregy[4][10];
	bool fuck = false; // indicates, that ro something can be unsafe
	for(int i=0; i<m; i++){
		int x;
		scanf("%s %s %d %s %s", sregy[0], sregy[1], &x, sregy[2], sregy[3]);
		if(*sregy[3] == 'B') stat[x] = -1;
		if(*sregy[3] == 'O') stat[x] = 1;
		if(*sregy[3] == 'O') fuck = true;
	}
	vector<int> ret, adj, notadj;
	if(!fuck){
		for(int i=1; i<=n; i++){
			if(chk[i]) ret.push_back(i);
		}
	}
	for(int i=1; i<=n; i++){
		if(stat[i] == -1 && !chk[i]) adj.push_back(i);
		if(stat[i] == 1 && !chk[i]) notadj.push_back(i);
	}
	for(auto &i : adj){
		for(auto &j : gph[i]) mp[j]++;
	}
	int sz = adj.size(); adj.clear();
	for(int i=1; i<=n; i++){
		if(mp[i] == sz && !chk[i]) adj.push_back(i);
	}
	memset(mp, 0, sizeof(mp));
	for(auto &i : notadj){
		for(auto &j : gph[i]) mp[j] = 1;
	}
	for(auto &i : adj){
		bool fuck = false;
		if(mp[i]) fuck = true;
		if(!fuck) ret.push_back(i);
	}
	sort(ret.begin(), ret.end());
	cout << ret.size() << endl;
	for(auto &i : ret) printf("%d ", i);
}

Compilation message

chocolate.cpp: In function 'int main()':
chocolate.cpp:10:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d",&n,&m,&k);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~
chocolate.cpp:13:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&x);
   ~~~~~^~~~~~~~~
chocolate.cpp:18:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d",&s,&e);
   ~~~~~^~~~~~~~~~~~~~~
chocolate.cpp:22:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&m);
  ~~~~~^~~~~~~~~
chocolate.cpp:27:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%s %s %d %s %s", sregy[0], sregy[1], &x, sregy[2], sregy[3]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 8568 KB Output is correct
2 Correct 9 ms 8676 KB Output is correct
3 Correct 14 ms 8996 KB Output is correct
4 Correct 104 ms 13172 KB Output is correct
5 Correct 10 ms 13172 KB Output is correct
6 Correct 10 ms 13172 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 572 ms 20668 KB Output is correct
2 Correct 124 ms 20668 KB Output is correct
3 Correct 409 ms 20668 KB Output is correct
4 Correct 880 ms 25488 KB Output is correct
5 Correct 402 ms 25488 KB Output is correct
6 Correct 88 ms 25488 KB Output is correct
7 Correct 990 ms 29192 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 8568 KB Output is correct
2 Correct 9 ms 8676 KB Output is correct
3 Correct 14 ms 8996 KB Output is correct
4 Correct 104 ms 13172 KB Output is correct
5 Correct 10 ms 13172 KB Output is correct
6 Correct 10 ms 13172 KB Output is correct
7 Correct 572 ms 20668 KB Output is correct
8 Correct 124 ms 20668 KB Output is correct
9 Correct 409 ms 20668 KB Output is correct
10 Correct 880 ms 25488 KB Output is correct
11 Correct 402 ms 25488 KB Output is correct
12 Correct 88 ms 25488 KB Output is correct
13 Correct 990 ms 29192 KB Output is correct
14 Correct 18 ms 29192 KB Output is correct
15 Correct 22 ms 29192 KB Output is correct
16 Correct 742 ms 29192 KB Output is correct
17 Correct 299 ms 29192 KB Output is correct
18 Correct 1110 ms 31476 KB Output is correct
19 Correct 1206 ms 31476 KB Output is correct
20 Correct 1151 ms 32280 KB Output is correct
21 Correct 1186 ms 32280 KB Output is correct
22 Correct 1026 ms 32280 KB Output is correct
23 Correct 1167 ms 32280 KB Output is correct