답안 #594002

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
594002 2022-07-11T21:12:10 Z AlperenT Simurgh (IOI17_simurgh) C++17
13 / 100
3000 ms 340 KB
#include <bits/stdc++.h>
#include "simurgh.h"

using namespace std;

const int N = 7;

struct DSU{
	int par[N], setsize[N], setcnt;

	void reset(int n){
		for(int i = 0; i < n; i++) par[i] = i, setsize[i] = 1;
		setcnt = n;
	}

	int setfind(int a){
		if(par[a] == a) return a;
		else return par[a] = setfind(par[a]);
	}

	void setunion(int a, int b){
		a = setfind(a), b = setfind(b);

		if(a != b){
			if(setsize[b] > setsize[a]) swap(a, b);
			par[b] = par[a];
			setsize[a] += setsize[b];
			setcnt--;
		}
	}
};

DSU dsu;

vector<int> find_roads(int n, vector<int> u, vector<int> v) {
	int m = u.size();

	for(int msk = 0; msk < (1 << m); msk++){
		if(__builtin_popcount(msk) == n - 1){
			dsu.reset(n);

			vector<int> vec;

			for(int i = 0; i < m; i++){
				if(msk & (1 << i)){
					vec.push_back(i);
					dsu.setunion(u[i], v[i]);
				}
			}

			if(dsu.setcnt == 1){
				if(count_common_roads(vec) == n - 1) return vec;
			}
		}
	}
}

Compilation message

simurgh.cpp: In function 'std::vector<int> find_roads(int, std::vector<int>, std::vector<int>)':
simurgh.cpp:56:1: warning: control reaches end of non-void function [-Wreturn-type]
   56 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 212 KB correct
2 Correct 18 ms 212 KB correct
3 Correct 22 ms 212 KB correct
4 Correct 1 ms 300 KB correct
5 Correct 1 ms 212 KB correct
6 Correct 2 ms 212 KB correct
7 Correct 0 ms 212 KB correct
8 Correct 1 ms 300 KB correct
9 Correct 1 ms 212 KB correct
10 Correct 1 ms 212 KB correct
11 Correct 1 ms 212 KB correct
12 Correct 1 ms 212 KB correct
13 Correct 10 ms 304 KB correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 212 KB correct
2 Correct 18 ms 212 KB correct
3 Correct 22 ms 212 KB correct
4 Correct 1 ms 300 KB correct
5 Correct 1 ms 212 KB correct
6 Correct 2 ms 212 KB correct
7 Correct 0 ms 212 KB correct
8 Correct 1 ms 300 KB correct
9 Correct 1 ms 212 KB correct
10 Correct 1 ms 212 KB correct
11 Correct 1 ms 212 KB correct
12 Correct 1 ms 212 KB correct
13 Correct 10 ms 304 KB correct
14 Execution timed out 3038 ms 212 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 212 KB correct
2 Correct 18 ms 212 KB correct
3 Correct 22 ms 212 KB correct
4 Correct 1 ms 300 KB correct
5 Correct 1 ms 212 KB correct
6 Correct 2 ms 212 KB correct
7 Correct 0 ms 212 KB correct
8 Correct 1 ms 300 KB correct
9 Correct 1 ms 212 KB correct
10 Correct 1 ms 212 KB correct
11 Correct 1 ms 212 KB correct
12 Correct 1 ms 212 KB correct
13 Correct 10 ms 304 KB correct
14 Execution timed out 3038 ms 212 KB Time limit exceeded
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB correct
2 Runtime error 1 ms 340 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 212 KB correct
2 Correct 18 ms 212 KB correct
3 Correct 22 ms 212 KB correct
4 Correct 1 ms 300 KB correct
5 Correct 1 ms 212 KB correct
6 Correct 2 ms 212 KB correct
7 Correct 0 ms 212 KB correct
8 Correct 1 ms 300 KB correct
9 Correct 1 ms 212 KB correct
10 Correct 1 ms 212 KB correct
11 Correct 1 ms 212 KB correct
12 Correct 1 ms 212 KB correct
13 Correct 10 ms 304 KB correct
14 Execution timed out 3038 ms 212 KB Time limit exceeded
15 Halted 0 ms 0 KB -