Submission #486176


Source Code Expand

Copy
#include<cstdio>
#include<algorithm>

int head[100],nxt[10100],to[10100],m;

int V,E,K;

bool selected[100];

void input(){
	scanf("%d%d%d",&V,&E,&K);
	for(int i=0;i<V;i++){
		head[i]=-1;
	}
	for(int i=0;i<E;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		nxt[m]=head[a];to[m]=b;head[a]=m;m++;
		nxt[m]=head[b];to[m]=a;head[b]=m;m++;
	}
}

void solve_small(){
	for(int stat=0;stat<(1<<V);stat++){
		int cnt=0;
		for(int i=0;i<V;i++){
			if((stat>>i)&1){
				cnt++;
				selected[i]=true;
			}
			else selected[i]=false;
		}
		if(cnt!=K) continue;
		bool ok=true;
		for(int v=0;v<V;v++){
			if(selected[v]){
				for(int e=head[v];e!=-1;e=nxt[e]){
					int u=to[e];
					if(selected[u]){
						ok=false;
						break;
					}
				}
			}
		}
		if(ok){
			for(int i=0;i<V;i++){
				if(selected[i]){
					printf("%d\n",i);
				}
			}
			return;
		}
	}
}

int main(){
	input();
	if(V<=20) solve_small();
	else printf("too large\n");
	return 0;
}

Submission Info

Submission Time
Task B - B 問題
User wo01
Language C++ (GCC 4.9.2)
Score 12
Code Size 993 Byte
Status
Exec Time 74 ms
Memory 800 KB

Compile Error

./Main.cpp: In function ‘void input()’:
./Main.cpp:11:26: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d",&V,&E,&K);
                          ^
./Main.cpp:17:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",&a,&b);
                      ^

Test Cases

Set Name Score / Max Score Test Cases
All 10 / 10 00_sample_1.txt, 00_sample_2.txt, 00_sample_3.txt, 20_random_1.txt, 20_random_10.txt, 20_random_11.txt, 20_random_12.txt, 20_random_13.txt, 20_random_14.txt, 20_random_15.txt, 20_random_16.txt, 20_random_17.txt, 20_random_18.txt, 20_random_19.txt, 20_random_2.txt, 20_random_20.txt, 20_random_21.txt, 20_random_22.txt, 20_random_23.txt, 20_random_24.txt, 20_random_25.txt, 20_random_26.txt, 20_random_27.txt, 20_random_28.txt, 20_random_29.txt, 20_random_3.txt, 20_random_30.txt, 20_random_4.txt, 20_random_5.txt, 20_random_6.txt, 20_random_7.txt, 20_random_8.txt, 20_random_9.txt
asi1024 0 / 2 31_asi1024.txt
atetubou 0 / 2 32_atetubou.txt
climpet 0 / 2 33_climpet.txt
DEGwer 0 / 2 34_DEGwer.txt
evima 0 / 2 35_evima.txt
flowlight 0 / 2 36_flowlight.txt
hogloid 0 / 2 37_hogloid.txt
ichyo 0 / 2 38_ichyo.txt
math 0 / 2 39_math.txt
miki_im 0 / 2 40_miki_im.txt
natsugiri 0 / 2 41_natsugiri.txt
piroz95 0 / 2 42_piroz95.txt
semiexp 0 / 2 43_semiexp.txt
sigma425 2 / 2 44_sigma425.txt
sky58 0 / 2 45_sky58.txt
snuke 0 / 2 46_snuke.txt
tozangezan 0 / 2 47_tozangezan.txt
wo01 0 / 2 48_wo01.txt
yosupo 0 / 2 49_yosupo.txt
zerokugi 0 / 2 50_zerokugi.txt
Case Name Status Exec Time Memory
00_sample_1.txt 23 ms 668 KB
00_sample_2.txt 25 ms 792 KB
00_sample_3.txt 25 ms 676 KB
20_random_1.txt 24 ms 792 KB
20_random_10.txt 25 ms 792 KB
20_random_11.txt 25 ms 788 KB
20_random_12.txt 24 ms 692 KB
20_random_13.txt 24 ms 696 KB
20_random_14.txt 24 ms 796 KB
20_random_15.txt 22 ms 792 KB
20_random_16.txt 21 ms 700 KB
20_random_17.txt 22 ms 696 KB
20_random_18.txt 21 ms 704 KB
20_random_19.txt 23 ms 652 KB
20_random_2.txt 23 ms 656 KB
20_random_20.txt 22 ms 696 KB
20_random_21.txt 22 ms 700 KB
20_random_22.txt 23 ms 800 KB
20_random_23.txt 74 ms 788 KB
20_random_24.txt 27 ms 792 KB
20_random_25.txt 25 ms 792 KB
20_random_26.txt 23 ms 792 KB
20_random_27.txt 26 ms 796 KB
20_random_28.txt 24 ms 796 KB
20_random_29.txt 30 ms 792 KB
20_random_3.txt 25 ms 784 KB
20_random_30.txt 25 ms 800 KB
20_random_4.txt 32 ms 696 KB
20_random_5.txt 27 ms 696 KB
20_random_6.txt 25 ms 800 KB
20_random_7.txt 25 ms 796 KB
20_random_8.txt 27 ms 796 KB
20_random_9.txt 24 ms 792 KB
31_asi1024.txt 22 ms 684 KB
32_atetubou.txt 22 ms 688 KB
33_climpet.txt 23 ms 800 KB
34_DEGwer.txt 25 ms 800 KB
35_evima.txt 24 ms 796 KB
36_flowlight.txt 24 ms 728 KB
37_hogloid.txt 24 ms 796 KB
38_ichyo.txt 21 ms 796 KB
39_math.txt 23 ms 716 KB
40_miki_im.txt 22 ms 748 KB
41_natsugiri.txt 25 ms 792 KB
42_piroz95.txt 24 ms 672 KB
43_semiexp.txt 22 ms 672 KB
44_sigma425.txt 23 ms 688 KB
45_sky58.txt 23 ms 792 KB
46_snuke.txt 24 ms 800 KB
47_tozangezan.txt 24 ms 672 KB
48_wo01.txt 23 ms 800 KB
49_yosupo.txt 23 ms 792 KB
50_zerokugi.txt 23 ms 672 KB