답안 #68969

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
68969 2018-08-19T11:43:42 Z 검수컵(#1978, imsifile) 초코쿠키 기계 (FXCUP3_chocolate) C++
100 / 100
1216 ms 29452 KB
#include<stdio.h>
#include<vector>
using namespace std;

int N, M, K, E, chk[301010], cnt[301010], rval, isok;
vector<int> con[301010], dap;

int main(){
	scanf("%d%d%d", &N, &M, &K);
	for(int i=0; i<M; i++){
		int a; scanf("%d", &a);
		chk[a]=1;
	}
	for(int i=0; i<K; i++){
		int a, b; scanf("%d%d", &a, &b);
		if(chk[a] || chk[b]) continue;
		con[a].push_back(b), con[b].push_back(a);
	}
	for(scanf("%d", &E); E--;){
		int a; char st[6];
		scanf("\nL + %d = %s", &a, &st);
		if(chk[a]) continue;
		if(st[0]=='O'){
			isok = 1;
			for(int i=0; i<con[a].size(); i++) cnt[con[a][i]]--;
		}
		else{
			rval++;
			for(int i=0; i<con[a].size(); i++) cnt[con[a][i]]++;
		}
	}
	for(int i=1; i<=N; i++){
		if(chk[i]){
			if(!isok) dap.push_back(i);
			continue;
		}
		if(cnt[i] == rval) dap.push_back(i);
	}
	printf("%d\n", dap.size());
	for(int i=0; i<dap.size(); i++){
		printf("%d", dap[i]);
		if(i < dap.size()-1) printf(" ");
		else printf("\n");
	}
	return 0;
}

Compilation message

chocolate.cpp: In function 'int main()':
chocolate.cpp:21:33: warning: format '%s' expects argument of type 'char*', but argument 3 has type 'char (*)[6]' [-Wformat=]
   scanf("\nL + %d = %s", &a, &st);
                              ~~~^
chocolate.cpp:25:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int i=0; i<con[a].size(); i++) cnt[con[a][i]]--;
                 ~^~~~~~~~~~~~~~
chocolate.cpp:29:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int i=0; i<con[a].size(); i++) cnt[con[a][i]]++;
                 ~^~~~~~~~~~~~~~
chocolate.cpp:39:27: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type {aka long unsigned int}' [-Wformat=]
  printf("%d\n", dap.size());
                 ~~~~~~~~~~^
chocolate.cpp:40:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<dap.size(); i++){
               ~^~~~~~~~~~~
chocolate.cpp:42:8: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(i < dap.size()-1) printf(" ");
      ~~^~~~~~~~~~~~~~
chocolate.cpp:9: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:11:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int a; scanf("%d", &a);
          ~~~~~^~~~~~~~~~
chocolate.cpp:15:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int a, b; scanf("%d%d", &a, &b);
             ~~~~~^~~~~~~~~~~~~~~~
chocolate.cpp:19:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(scanf("%d", &E); E--;){
      ~~~~~^~~~~~~~~~
chocolate.cpp:21:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("\nL + %d = %s", &a, &st);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 7288 KB Output is correct
2 Correct 8 ms 7396 KB Output is correct
3 Correct 13 ms 7704 KB Output is correct
4 Correct 94 ms 11620 KB Output is correct
5 Correct 9 ms 11620 KB Output is correct
6 Correct 9 ms 11620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 521 ms 19220 KB Output is correct
2 Correct 80 ms 19220 KB Output is correct
3 Correct 217 ms 19220 KB Output is correct
4 Correct 835 ms 24216 KB Output is correct
5 Correct 209 ms 24216 KB Output is correct
6 Correct 47 ms 24216 KB Output is correct
7 Correct 865 ms 25304 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 7288 KB Output is correct
2 Correct 8 ms 7396 KB Output is correct
3 Correct 13 ms 7704 KB Output is correct
4 Correct 94 ms 11620 KB Output is correct
5 Correct 9 ms 11620 KB Output is correct
6 Correct 9 ms 11620 KB Output is correct
7 Correct 521 ms 19220 KB Output is correct
8 Correct 80 ms 19220 KB Output is correct
9 Correct 217 ms 19220 KB Output is correct
10 Correct 835 ms 24216 KB Output is correct
11 Correct 209 ms 24216 KB Output is correct
12 Correct 47 ms 24216 KB Output is correct
13 Correct 865 ms 25304 KB Output is correct
14 Correct 15 ms 25304 KB Output is correct
15 Correct 22 ms 25304 KB Output is correct
16 Correct 745 ms 25304 KB Output is correct
17 Correct 186 ms 25304 KB Output is correct
18 Correct 970 ms 29452 KB Output is correct
19 Correct 1216 ms 29452 KB Output is correct
20 Correct 1162 ms 29452 KB Output is correct
21 Correct 904 ms 29452 KB Output is correct
22 Correct 1010 ms 29452 KB Output is correct
23 Correct 767 ms 29452 KB Output is correct