Submission #478705

# Submission time Handle Problem Language Result Execution time Memory
478705 2021-10-08T07:31:14 Z CSQ31 Newspapers (CEOI21_newspapers) C++17
4 / 100
2 ms 460 KB
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e5+1;
int cnt[MAXN+1];
#define pb push_back
#define sz(a) (int)(a.size())
typedef long long int ll;
typedef vector<vector<int>>vii;
vii adj(1111);
bool ok = 1,vis[1111];
void dfs(int v,int u){
	vis[v] = 1;
	for(int x:adj[v]){
		if(x == u)continue;
		if(vis[x])ok = 0;
		else dfs(x,v);
		
	}
}
int d = 0;
int dfs2(int v,int u){
	int d1 = 0,d2 = 0;
	vector<int>c;
	for(int x:adj[v]){
		if(x == u)continue;
		int d = dfs2(x,v)+1;
		c.pb(d);
		if(d > d1){
			d2=d1;
			d1=d;
		}else if(d > d2){
			d2=d;
		}
	}
	int cnt = 0;
	for(int x:c)if(x > 1)cnt++;
	if(cnt>=3)ok = 0;
	d=max(d,d1+d2);
	return d1;
}
int main()
{
	//the graph must be a tree
	//if have cycle then bob's possible space never decreases around the cycle
	//how to solve when have tree?
	
	//think about search space of bob
	//each turn a on state becomes off and turn everything incident to it on
	//alice can pick a node and off it
	//can she make everything off?
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int v,u;
		cin>>v>>u;
		adj[v].pb(u);
		adj[u].pb(v);
	}
	dfs(1,0);
	if(ok){
		dfs2(1,0);
		cout<<"YES"<<'\n';
		cout<<2<<'\n';
		cout<<1<<" "<<1;
	}
	else cout<<"NO";
	
	
}
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 204 KB Provide a successful but not optimal strategy.
2 Correct 1 ms 332 KB Output is correct
3 Partially correct 0 ms 332 KB Failed to provide a successful strategy.
4 Partially correct 0 ms 332 KB Failed to provide a successful strategy.
5 Correct 1 ms 332 KB Output is correct
6 Partially correct 0 ms 204 KB Failed to provide a successful strategy.
7 Correct 0 ms 332 KB Output is correct
8 Partially correct 1 ms 332 KB Failed to provide a successful strategy.
9 Incorrect 0 ms 332 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 1 ms 204 KB Provide a successful but not optimal strategy.
2 Correct 1 ms 204 KB Output is correct
3 Partially correct 0 ms 204 KB Failed to provide a successful strategy.
4 Partially correct 1 ms 332 KB Failed to provide a successful strategy.
5 Partially correct 0 ms 204 KB Failed to provide a successful strategy.
6 Partially correct 0 ms 332 KB Failed to provide a successful strategy.
7 Partially correct 1 ms 204 KB Failed to provide a successful strategy.
8 Partially correct 0 ms 332 KB Failed to provide a successful strategy.
9 Partially correct 0 ms 204 KB Failed to provide a successful strategy.
10 Partially correct 0 ms 204 KB Failed to provide a successful strategy.
11 Partially correct 1 ms 460 KB Failed to provide a successful strategy.
12 Partially correct 1 ms 332 KB Failed to provide a successful strategy.
13 Partially correct 1 ms 332 KB Failed to provide a successful strategy.
14 Partially correct 1 ms 332 KB Failed to provide a successful strategy.
15 Partially correct 1 ms 332 KB Failed to provide a successful strategy.
16 Partially correct 2 ms 460 KB Failed to provide a successful strategy.
17 Partially correct 1 ms 460 KB Failed to provide a successful strategy.
18 Partially correct 1 ms 460 KB Failed to provide a successful strategy.
19 Partially correct 1 ms 460 KB Failed to provide a successful strategy.
20 Partially correct 1 ms 460 KB Failed to provide a successful strategy.
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 204 KB Provide a successful but not optimal strategy.
2 Correct 1 ms 332 KB Output is correct
3 Partially correct 0 ms 332 KB Failed to provide a successful strategy.
4 Partially correct 0 ms 332 KB Failed to provide a successful strategy.
5 Correct 1 ms 332 KB Output is correct
6 Partially correct 0 ms 204 KB Failed to provide a successful strategy.
7 Correct 0 ms 332 KB Output is correct
8 Partially correct 1 ms 332 KB Failed to provide a successful strategy.
9 Incorrect 0 ms 332 KB Output isn't correct
10 Halted 0 ms 0 KB -