답안 #516187

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
516187 2022-01-20T15:02:57 Z mosiashvililuka Newspapers (CEOI21_newspapers) C++14
75 / 100
66 ms 4552 KB
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e,i,j,ii,jj,zx,xc,p[5009],pi,kl[1003][1003],DP[1009],l[5009],li,bo[5009];
int CH[1009][1009];
vector <int> v[1009];
void print(){
	cout<<"YES\n";
	cout<<pi<<"\n";
	for(i=1; i<=pi; i++){
		cout<<p[i]<<" ";
	}
	/*
	cout<<"\n";
	for(i=1; i<=a; i++) CH[0][i]=1;
	for(j=1; j<=pi; j++){
		for(i=1; i<=a; i++){
			CH[j][i]=0;
			for(vector <int>::iterator it=v[i].begin(); it!=v[i].end(); it++){
				if(p[j]!=(*it)&&CH[j-1][(*it)]==1){
					CH[j][i]=1;break;
				}
			}
		}
	}
	e=0;
	for(i=1; i<=a; i++){
		if(CH[pi][i]==1) e++;
	}
	cout<<"WRONG: "<<e;
	*/
	exit(0);
}
void dfs(int q, int w, int rr){
	e=max(e,rr);
	for(vector <int>::iterator it=v[q].begin(); it!=v[q].end(); it++){
		if((*it)==w) continue;
		dfs((*it),q,rr+1);
	}
}
void dfs2(int q, int w){
	li++;l[li]=q;bo[q]=1;
	if(DP[q]-kl[q][w]==0){
		pi=0;
		for(j=1; j<=li; j++){
			pi++;p[pi]=l[j];
			for(vector <int>::iterator it=v[l[j]].begin(); it!=v[l[j]].end(); it++){
				if(bo[(*it)]==1) continue;
				if(v[(*it)].size()!=1){
					pi++;p[pi]=(*it);
					pi++;p[pi]=l[j];
				}
			}
		}
		for(i=pi; i>=1; i--){
			pi++;p[pi]=p[i];
		}
		print();
	}
	for(vector <int>::iterator it=v[q].begin(); it!=v[q].end(); it++){
		if((*it)==w) continue;
		if(DP[q]-kl[q][w]-kl[q][(*it)]!=0) continue;
		dfs2((*it),q);
	}
	li--;bo[q]=0;
}
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>a>>b;
	for(i=1; i<=b; i++){
		cin>>c>>d;
		v[c].push_back(d);
		v[d].push_back(c);
	}
	if(a==1){
		pi=1;p[1]=1;
		print();
	}
	if(a==2){
		pi=2;p[1]=1;p[2]=1;
		print();
	}
	if(b!=a-1){
		cout<<"NO";
		return 0;
	}
	for(i=1; i<=a; i++){
		for(vector <int>::iterator it=v[i].begin(); it!=v[i].end(); it++){
			e=0;
			dfs((*it),i,1);
			if(e>2){
				kl[i][(*it)]=1;DP[i]++;
			}
		}
	}
	for(i=1; i<=a; i++){
		dfs2(i,0);
	}
	cout<<"NO";
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
4 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
5 Correct 1 ms 332 KB Output is correct
6 Partially correct 1 ms 332 KB Provide a successful but not optimal strategy.
7 Correct 0 ms 332 KB Output is correct
8 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
9 Correct 0 ms 332 KB Output is correct
10 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
11 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
12 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
13 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
14 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
15 Partially correct 1 ms 332 KB Provide a successful but not optimal strategy.
16 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
17 Partially correct 1 ms 332 KB Provide a successful but not optimal strategy.
18 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
19 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
20 Partially correct 1 ms 332 KB Provide a successful but not optimal strategy.
21 Partially correct 1 ms 332 KB Provide a successful but not optimal strategy.
22 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
23 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
24 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
25 Partially correct 1 ms 332 KB Provide a successful but not optimal strategy.
26 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
27 Partially correct 1 ms 332 KB Provide a successful but not optimal strategy.
28 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
29 Correct 0 ms 332 KB Output is correct
30 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
31 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
32 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
33 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
34 Correct 0 ms 332 KB Output is correct
35 Partially correct 1 ms 332 KB Provide a successful but not optimal strategy.
36 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
37 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
38 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
39 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
40 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
41 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
42 Partially correct 1 ms 332 KB Provide a successful but not optimal strategy.
43 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
44 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
45 Correct 0 ms 332 KB Output is correct
46 Correct 0 ms 332 KB Output is correct
47 Correct 0 ms 332 KB Output is correct
48 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
49 Correct 0 ms 332 KB Output is correct
50 Correct 0 ms 332 KB Output is correct
51 Partially correct 1 ms 332 KB Provide a successful but not optimal strategy.
52 Correct 0 ms 332 KB Output is correct
53 Correct 0 ms 332 KB Output is correct
54 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
55 Correct 0 ms 332 KB Output is correct
56 Correct 0 ms 332 KB Output is correct
57 Correct 0 ms 332 KB Output is correct
58 Correct 1 ms 332 KB Output is correct
59 Correct 0 ms 332 KB Output is correct
60 Correct 0 ms 332 KB Output is correct
61 Correct 1 ms 264 KB Output is correct
62 Correct 0 ms 332 KB Output is correct
63 Correct 0 ms 332 KB Output is correct
64 Correct 0 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
4 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
5 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
6 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
7 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
8 Partially correct 1 ms 332 KB Provide a successful but not optimal strategy.
9 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
10 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
11 Partially correct 10 ms 4172 KB Provide a successful but not optimal strategy.
12 Partially correct 4 ms 2380 KB Provide a successful but not optimal strategy.
13 Partially correct 5 ms 2764 KB Provide a successful but not optimal strategy.
14 Partially correct 5 ms 2892 KB Provide a successful but not optimal strategy.
15 Partially correct 6 ms 3020 KB Provide a successful but not optimal strategy.
16 Partially correct 11 ms 4300 KB Provide a successful but not optimal strategy.
17 Partially correct 11 ms 4312 KB Provide a successful but not optimal strategy.
18 Partially correct 13 ms 4300 KB Provide a successful but not optimal strategy.
19 Partially correct 11 ms 4304 KB Provide a successful but not optimal strategy.
20 Partially correct 12 ms 4416 KB Provide a successful but not optimal strategy.
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
4 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
5 Correct 1 ms 332 KB Output is correct
6 Partially correct 1 ms 332 KB Provide a successful but not optimal strategy.
7 Correct 0 ms 332 KB Output is correct
8 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
9 Correct 0 ms 332 KB Output is correct
10 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
11 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
12 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
13 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
14 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
15 Partially correct 1 ms 332 KB Provide a successful but not optimal strategy.
16 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
17 Partially correct 1 ms 332 KB Provide a successful but not optimal strategy.
18 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
19 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
20 Partially correct 1 ms 332 KB Provide a successful but not optimal strategy.
21 Partially correct 1 ms 332 KB Provide a successful but not optimal strategy.
22 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
23 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
24 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
25 Partially correct 1 ms 332 KB Provide a successful but not optimal strategy.
26 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
27 Partially correct 1 ms 332 KB Provide a successful but not optimal strategy.
28 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
29 Correct 0 ms 332 KB Output is correct
30 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
31 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
32 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
33 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
34 Correct 0 ms 332 KB Output is correct
35 Partially correct 1 ms 332 KB Provide a successful but not optimal strategy.
36 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
37 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
38 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
39 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
40 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
41 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
42 Partially correct 1 ms 332 KB Provide a successful but not optimal strategy.
43 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
44 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
45 Correct 0 ms 332 KB Output is correct
46 Correct 0 ms 332 KB Output is correct
47 Correct 0 ms 332 KB Output is correct
48 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
49 Correct 0 ms 332 KB Output is correct
50 Correct 0 ms 332 KB Output is correct
51 Partially correct 1 ms 332 KB Provide a successful but not optimal strategy.
52 Correct 0 ms 332 KB Output is correct
53 Correct 0 ms 332 KB Output is correct
54 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
55 Correct 0 ms 332 KB Output is correct
56 Correct 0 ms 332 KB Output is correct
57 Correct 0 ms 332 KB Output is correct
58 Correct 1 ms 332 KB Output is correct
59 Correct 0 ms 332 KB Output is correct
60 Correct 0 ms 332 KB Output is correct
61 Correct 1 ms 264 KB Output is correct
62 Correct 0 ms 332 KB Output is correct
63 Correct 0 ms 332 KB Output is correct
64 Correct 0 ms 332 KB Output is correct
65 Correct 0 ms 332 KB Output is correct
66 Correct 1 ms 332 KB Output is correct
67 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
68 Partially correct 1 ms 332 KB Provide a successful but not optimal strategy.
69 Correct 0 ms 332 KB Output is correct
70 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
71 Correct 0 ms 332 KB Output is correct
72 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
73 Correct 0 ms 332 KB Output is correct
74 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
75 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
76 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
77 Partially correct 0 ms 332 KB Provide a successful but not optimal strategy.
78 Partially correct 1 ms 332 KB Provide a successful but not optimal strategy.
79 Correct 10 ms 3404 KB Output is correct
80 Correct 9 ms 3472 KB Output is correct
81 Correct 14 ms 3532 KB Output is correct
82 Correct 13 ms 3788 KB Output is correct
83 Correct 12 ms 3656 KB Output is correct
84 Correct 10 ms 3460 KB Output is correct
85 Correct 14 ms 3532 KB Output is correct
86 Correct 9 ms 3532 KB Output is correct
87 Correct 11 ms 3616 KB Output is correct
88 Correct 9 ms 3276 KB Output is correct
89 Partially correct 19 ms 3820 KB Provide a successful but not optimal strategy.
90 Partially correct 15 ms 3404 KB Provide a successful but not optimal strategy.
91 Partially correct 14 ms 3284 KB Provide a successful but not optimal strategy.
92 Partially correct 11 ms 3136 KB Provide a successful but not optimal strategy.
93 Partially correct 18 ms 3748 KB Provide a successful but not optimal strategy.
94 Partially correct 13 ms 3292 KB Provide a successful but not optimal strategy.
95 Partially correct 19 ms 3920 KB Provide a successful but not optimal strategy.
96 Partially correct 20 ms 3804 KB Provide a successful but not optimal strategy.
97 Partially correct 11 ms 3072 KB Provide a successful but not optimal strategy.
98 Partially correct 19 ms 3792 KB Provide a successful but not optimal strategy.
99 Partially correct 14 ms 3388 KB Provide a successful but not optimal strategy.
100 Partially correct 19 ms 3488 KB Provide a successful but not optimal strategy.
101 Partially correct 15 ms 3424 KB Provide a successful but not optimal strategy.
102 Partially correct 14 ms 3336 KB Provide a successful but not optimal strategy.
103 Partially correct 17 ms 3432 KB Provide a successful but not optimal strategy.
104 Partially correct 11 ms 3020 KB Provide a successful but not optimal strategy.
105 Partially correct 14 ms 3268 KB Provide a successful but not optimal strategy.
106 Partially correct 16 ms 3532 KB Provide a successful but not optimal strategy.
107 Partially correct 14 ms 3276 KB Provide a successful but not optimal strategy.
108 Partially correct 19 ms 3760 KB Provide a successful but not optimal strategy.
109 Partially correct 15 ms 3480 KB Provide a successful but not optimal strategy.
110 Partially correct 15 ms 3580 KB Provide a successful but not optimal strategy.
111 Partially correct 12 ms 3200 KB Provide a successful but not optimal strategy.
112 Partially correct 13 ms 3328 KB Provide a successful but not optimal strategy.
113 Partially correct 19 ms 3832 KB Provide a successful but not optimal strategy.
114 Partially correct 16 ms 3532 KB Provide a successful but not optimal strategy.
115 Partially correct 14 ms 3380 KB Provide a successful but not optimal strategy.
116 Partially correct 16 ms 3580 KB Provide a successful but not optimal strategy.
117 Partially correct 25 ms 3912 KB Provide a successful but not optimal strategy.
118 Partially correct 17 ms 3620 KB Provide a successful but not optimal strategy.
119 Partially correct 16 ms 3336 KB Provide a successful but not optimal strategy.
120 Partially correct 17 ms 3560 KB Provide a successful but not optimal strategy.
121 Partially correct 16 ms 3588 KB Provide a successful but not optimal strategy.
122 Partially correct 13 ms 3276 KB Provide a successful but not optimal strategy.
123 Partially correct 13 ms 3276 KB Provide a successful but not optimal strategy.
124 Partially correct 20 ms 3812 KB Provide a successful but not optimal strategy.
125 Partially correct 11 ms 3112 KB Provide a successful but not optimal strategy.
126 Partially correct 12 ms 3148 KB Provide a successful but not optimal strategy.
127 Partially correct 11 ms 3164 KB Provide a successful but not optimal strategy.
128 Partially correct 19 ms 3788 KB Provide a successful but not optimal strategy.
129 Correct 15 ms 4044 KB Output is correct
130 Correct 16 ms 3948 KB Output is correct
131 Correct 15 ms 3940 KB Output is correct
132 Correct 15 ms 4016 KB Output is correct
133 Correct 15 ms 4056 KB Output is correct
134 Correct 15 ms 1228 KB Output is correct
135 Correct 14 ms 1364 KB Output is correct
136 Correct 32 ms 3828 KB Output is correct
137 Correct 18 ms 2252 KB Output is correct
138 Correct 32 ms 2756 KB Output is correct
139 Correct 63 ms 4552 KB Output is correct
140 Correct 9 ms 972 KB Output is correct
141 Correct 4 ms 588 KB Output is correct
142 Correct 60 ms 4464 KB Output is correct
143 Correct 66 ms 4320 KB Output is correct
144 Partially correct 12 ms 4408 KB Provide a successful but not optimal strategy.
145 Partially correct 12 ms 4332 KB Provide a successful but not optimal strategy.