# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
546389 | 2022-04-07T12:33:52 Z | yutabi | Newspapers (CEOI21_newspapers) | C++14 | 1 ms | 340 KB |
#include <bits/stdc++.h> using namespace std; #define pb push_back int n,m; int start; vector <vector <int> > tree; vector <int> ans; int main() { scanf("%d %d",&n,&m); if(n==1) { printf("YES\n1\n1"); return 0; } if(n==2) { printf("YES\n2\n1 1"); return 0; } if(m>=n) { printf("NO"); return 0; } tree=vector <vector <int> > (n); for(int i=0;i<m;i++) { int a,b; scanf(" %d %d",&a,&b); a--,b--; tree[a].pb(b); tree[b].pb(a); } for(int i=0;i<n;i++) { if(tree[i].size()==1) { continue; } int a=0; for(int j=0;j<tree[i].size();j++) { if(tree[tree[i][j]].size()!=1) { a++; } } if(a==1) { start=i; } if(a>2) { printf("NO"); return 0; } } int curr=start; int last=-1; while(1) { if(ans.size() && ans.back()==curr) { break; } ans.pb(curr); for(int i=0;i<tree[curr].size();i++) { if(tree[curr][i]!=last && tree[tree[curr][i]].size()!=1) { last=curr; curr=tree[curr][i]; break; } } } printf("YES\n%d\n",ans.size()*2); for(int i=0;i<ans.size();i++) { printf("%d ",ans[i]+1); } for(int i=ans.size()-1;i>=0;i--) { printf("%d ",ans[i]+1); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 300 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 300 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Incorrect | 0 ms | 340 KB | Output isn't correct |
9 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Partially correct | 1 ms | 296 KB | Provide a successful but not optimal strategy. |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 296 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 300 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 296 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 308 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Correct | 1 ms | 340 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 1 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 1 ms | 340 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 300 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 300 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Incorrect | 0 ms | 340 KB | Output isn't correct |
9 | Halted | 0 ms | 0 KB | - |