Submission #72688

#TimeUsernameProblemLanguageResultExecution timeMemory
72688gs14004Chocolate Cookie Machine (FXCUP3_chocolate)C++17
100 / 100
1224 ms42992 KiB
#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 (stderr)

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]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...