#include <bits/extc++.h>
using namespace std;
using namespace __gnu_pbds;
typedef int64_t ll;
typedef long double ld;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define pb emplace_back
#define mp make_pair
#define mt make_tuple
#define pii pair<int,int>
#define F(n) Fi(i,n)
#define Fi(i,n) Fl(i,0,n)
#define Fl(i,l,n) for(int i=l;i<n;i++)
#define RF(n) RFi(i,n)
#define RFi(i,n) RFl(i,0,n)
#define RFl(i,l,n) for(int i=n-1;i>=l;i--)
#define all(v) begin(v),end(v)
#define siz(v) (ll(v.size()))
#define get_pos(v,x) (lower_bound(all(v),x)-begin(v))
#define sort_uni(v) sort(begin(v),end(v)),v.erase(unique(begin(v),end(v)),end(v))
#define mem(v,x) memset(v,x,sizeof v)
#define ff first
#define ss second
#define mid ((l+r)>>1)
#define RAN(a,b) uniform_int_distribution<int> (a, b)(rng)
template <typename T> using max_heap = __gnu_pbds::priority_queue<T,less<T> >;
template <typename T> using min_heap = __gnu_pbds::priority_queue<T,greater<T> >;
template <typename T> using rbt = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
const int maxN = 1010;
vector<int> edges[maxN];
signed main(){
int n,m;
cin >> n >> m;
F(m){
int x,y;
cin >> x >> y;
edges[x].pb(y);
edges[y].pb(x);
}
if(n == 1){
printf("YES\n1\n1");
exit(0);
}
if(n == 2){
printf("YES\n2\n1 1");
exit(0);
}
if(m == n-1){
bool chain = true;
int head;
Fl(i, 1, n+1){
if(edges[i].size() >= 2){
chain = false;
break;
}else{
if(edges[i].size() == 1){
head = i;
}
}
if(chain){
printf("YES\n");
printf("%d\n", 2 * (n-1));
F(n-1) printf("%d ", i+2);
F(n-1) printf("%d ", i+2);
}else{
printf("YES\n1\n1");
}
}
}else{
printf("NO\n");
}
return 0;
}
Compilation message
newspapers.cpp: In function 'int main()':
newspapers.cpp:55:9: warning: variable 'head' set but not used [-Wunused-but-set-variable]
55 | int head;
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Partially correct |
1 ms |
204 KB |
Failed to provide a successful strategy. |
4 |
Partially correct |
0 ms |
204 KB |
Provide a successful but not optimal strategy. |
5 |
Incorrect |
0 ms |
204 KB |
Unexpected end of file - token expected |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
216 KB |
Output is correct |
3 |
Partially correct |
0 ms |
204 KB |
Failed to provide a successful strategy. |
4 |
Partially correct |
1 ms |
316 KB |
Provide a successful but not optimal strategy. |
5 |
Partially correct |
0 ms |
204 KB |
Failed to provide a successful strategy. |
6 |
Partially correct |
1 ms |
204 KB |
Provide a successful but not optimal strategy. |
7 |
Partially correct |
0 ms |
204 KB |
Failed to provide a successful strategy. |
8 |
Partially correct |
0 ms |
204 KB |
Provide a successful but not optimal strategy. |
9 |
Partially correct |
0 ms |
204 KB |
Failed to provide a successful strategy. |
10 |
Partially correct |
0 ms |
204 KB |
Provide a successful but not optimal strategy. |
11 |
Partially correct |
1 ms |
332 KB |
Provide a successful but not optimal strategy. |
12 |
Partially correct |
1 ms |
320 KB |
Failed to provide a successful strategy. |
13 |
Partially correct |
1 ms |
332 KB |
Provide a successful but not optimal strategy. |
14 |
Partially correct |
1 ms |
332 KB |
Provide a successful but not optimal strategy. |
15 |
Partially correct |
1 ms |
332 KB |
Failed to provide a successful strategy. |
16 |
Partially correct |
1 ms |
332 KB |
Provide a successful but not optimal strategy. |
17 |
Partially correct |
1 ms |
332 KB |
Failed to provide a successful strategy. |
18 |
Partially correct |
1 ms |
332 KB |
Provide a successful but not optimal strategy. |
19 |
Partially correct |
1 ms |
332 KB |
Failed to provide a successful strategy. |
20 |
Partially correct |
2 ms |
332 KB |
Provide a successful but not optimal strategy. |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Partially correct |
1 ms |
204 KB |
Failed to provide a successful strategy. |
4 |
Partially correct |
0 ms |
204 KB |
Provide a successful but not optimal strategy. |
5 |
Incorrect |
0 ms |
204 KB |
Unexpected end of file - token expected |
6 |
Halted |
0 ms |
0 KB |
- |