답안 #527288

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
527288 2022-02-17T05:24:24 Z hmm789 Potemkin cycle (CEOI15_indcyc) C++14
10 / 100
1000 ms 4592 KB
#include <bits/stdc++.h>
using namespace std;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n, e, a, b, sz = 1e9;
	cin >> n >> e;
	int adj[n][n];
	memset(adj, 0, sizeof(adj));
	for(int i = 0; i < e; i++) {
		cin >> a >> b;
		if(a == b) continue;
		a--; b--;
		adj[a][b] = 1;
		adj[b][a] = 1;
	}
	vector<int> v, ans;
	for(int i = 0; i < (1<<n); i++) {
		v.clear();
		for(int j = 0; j < n; j++) {
			if(i & (1<<j)) v.push_back(j);
		}
		if(v.size() < 4) continue;
		int cnt[v.size()];
		memset(cnt, 0, sizeof(cnt));
		for(int i = 0; i < v.size(); i++) {
			for(int j = 0; j < v.size(); j++) {
				if(adj[v[i]][v[j]]) cnt[i]++;
			}
		}
		for(int i = 0; i < v.size(); i++) if(cnt[i] != 2) goto end2;
		for(int i = 0; i < v.size(); i++) {
			for(int j = 0; j < v.size(); j++) {
				for(int k = 0; k < v.size(); k++) {
					if(adj[v[i]][v[j]] && adj[v[j]][v[k]] && adj[v[k]][v[i]]) {
						goto end2;
					}
				}
			}
		}
		if(v.size() < sz) {
			sz = v.size();
			ans.clear();
			for(int i : v) ans.push_back(i);
		}
		end2:;
	}
	if(sz == 1e9) cout << "no";
	else for(int i : ans) cout << i+1 << " ";
}

Compilation message

indcyc.cpp: In function 'int main()':
indcyc.cpp:27:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |   for(int i = 0; i < v.size(); i++) {
      |                  ~~^~~~~~~~~~
indcyc.cpp:28:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |    for(int j = 0; j < v.size(); j++) {
      |                   ~~^~~~~~~~~~
indcyc.cpp:32:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |   for(int i = 0; i < v.size(); i++) if(cnt[i] != 2) goto end2;
      |                  ~~^~~~~~~~~~
indcyc.cpp:33:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |   for(int i = 0; i < v.size(); i++) {
      |                  ~~^~~~~~~~~~
indcyc.cpp:34:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |    for(int j = 0; j < v.size(); j++) {
      |                   ~~^~~~~~~~~~
indcyc.cpp:35:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     for(int k = 0; k < v.size(); k++) {
      |                    ~~^~~~~~~~~~
indcyc.cpp:42:15: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   42 |   if(v.size() < sz) {
      |      ~~~~~~~~~^~~~
indcyc.cpp:25:7: warning: argument to variable-length array may be too large [-Wvla-larger-than=]
   25 |   int cnt[v.size()];
      |       ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 308 KB Output is correct
3 Correct 1 ms 308 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Wrong adjacency
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Wrong adjacency
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 332 KB Expected integer, but "no" found
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 336 KB Expected integer, but "no" found
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 36 ms 676 KB Output is correct
2 Incorrect 35 ms 588 KB Expected integer, but "no" found
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 33 ms 588 KB Expected integer, but "no" found
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 22 ms 4592 KB Expected integer, but "no" found
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 14 ms 4376 KB Expected integer, but "no" found
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1072 ms 1740 KB Time limit exceeded
2 Halted 0 ms 0 KB -