Submission #257270

# Submission time Handle Problem Language Result Execution time Memory
257270 2020-08-04T03:16:22 Z super_j6 Potemkin cycle (CEOI15_indcyc) C++14
20 / 100
16 ms 2048 KB
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string.h>
#include <set>
using namespace std;
#define endl '\n'
#define ll long long
#define pi pair<int, int>
#define f first
#define s second
 
const int mxn = 1000;
int n, m;
int d[mxn], p[mxn];
vector<int> g[mxn];
set<int, greater<int>> s;
 
void dfs(int c){
	bool t = 0;
	//for(int i : g[c]) t |= (~d[i] && d[c] - d[i] == 2);
	if(t){
		s.insert(d[c] - 2);
	}else{
		int x = -1;
		for(int i : g[c]) if(i != p[c] && ~d[i] && (!~x || d[i] > d[x])) x = i;
		if(~x && (s.empty() || d[x] > *s.begin())){
			cout << c + 1;
			for(int i = p[c]; ~i && d[i] >= d[x]; i = p[i]) cout << " " << i + 1;
			cout << endl;
			exit(0);
		}
	}
	for(int i : g[c]){
		if(~d[i]) continue;
		d[i] = d[c] + 1, p[i] = c;
		dfs(i);
	}
	if(t) s.erase(d[c] - 2);
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> m;
	
	for(int i = 0; i < m; i++){
		int u, v;
		cin >> u >> v;
		u--, v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	
	for(int i = 0; i < n; i++){
		memset(d, -1, sizeof(d));
		d[i] = 0, p[i] = -1;
		dfs(i);
	}
	
	cout << "no" << endl;
 
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Incorrect 1 ms 384 KB Wrong answer on graph without induced cycle
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Too short sequence
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Too short sequence
2 Incorrect 0 ms 384 KB Wrong answer on graph without induced cycle
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Too short sequence
2 Incorrect 1 ms 384 KB Wrong answer on graph without induced cycle
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Wrong answer on graph without induced cycle
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Too short sequence
2 Incorrect 1 ms 384 KB Wrong answer on graph without induced cycle
# Verdict Execution time Memory Grader output
1 Correct 9 ms 1280 KB Too short sequence
2 Correct 5 ms 896 KB Too short sequence
3 Incorrect 8 ms 1280 KB Wrong answer on graph without induced cycle
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 768 KB Too short sequence
2 Incorrect 5 ms 848 KB Wrong answer on graph without induced cycle
# Verdict Execution time Memory Grader output
1 Correct 16 ms 2048 KB Too short sequence
2 Incorrect 16 ms 2048 KB Wrong answer on graph without induced cycle
3 Halted 0 ms 0 KB -