답안 #1079047

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1079047 2024-08-28T09:56:51 Z Gray Simurgh (IOI17_simurgh) C++17
13 / 100
15 ms 440 KB
#include "simurgh.h"
#include <bits/stdc++.h>
using namespace std;
#define ll int
#define ff first
#define ss second
#define ln "\n"
#define ld long double

vector<pair<ll, ll>> e;
vector<vector<ll>> A;
vector<ll> checka;
void dfs(ll u, vector<bool> &vis, ll mask){
	vis[u]=1;
	for (auto i:A[u]){
		if (mask&(1<<i)){
			ll v = e[i].ff^e[i].ss^u;
			if (vis[v]) continue;
			dfs(v, vis, mask);
		}
	}
}
bool check(ll mask, ll n, ll m){
	checka.clear();
	vector<bool> vis(n);
	dfs(0, vis, mask);
	for (ll i=0; i<n; i++) if (!vis[i]) return 0;
	for (ll i=0; i<m; i++){
		if (mask&(1<<i)) checka.push_back(i);
	}
	return 1;
}

// Slow version
vector<int> find_roads(int _n, vector<int> u, vector<int> v) {
	int n=_n, m=u.size();
	e.resize(m); A.clear(); A.resize(n);
	for (ll i=0; i<m; i++){
		e[i]={u[i], v[i]};
		A[u[i]].push_back(i); A[v[i]].push_back(i);
	}
	vector<ll> ans;
	// cout << (1ll<<21) << ln;
	for (ll i=0; i<(1ll<<m); i++){
		// cout << i << "-";
		// cout << i << "-" << (1ll<<m) << ln;
		if (__builtin_popcount(i)==n-1){
			// cout << i << ": ";
			if (check(i, n, m)) {
				// cout << "Check: ";
				// for (auto ch:checka) cout << ch << " ";
				// cout << ln;
				ll ret = count_common_roads(checka);
				// cout << "FOUND: " << ": ";
				if (ret==n-1){
					ans=checka; break;
				}
			}
			// cout << ln;
		}
	}
	// assert(ans.size());
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 344 KB correct
2 Correct 13 ms 348 KB correct
3 Correct 15 ms 440 KB correct
4 Correct 1 ms 348 KB correct
5 Correct 0 ms 344 KB correct
6 Correct 1 ms 432 KB correct
7 Correct 1 ms 348 KB correct
8 Correct 0 ms 348 KB correct
9 Correct 0 ms 348 KB correct
10 Correct 1 ms 348 KB correct
11 Correct 0 ms 348 KB correct
12 Correct 1 ms 348 KB correct
13 Correct 6 ms 348 KB correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 344 KB correct
2 Correct 13 ms 348 KB correct
3 Correct 15 ms 440 KB correct
4 Correct 1 ms 348 KB correct
5 Correct 0 ms 344 KB correct
6 Correct 1 ms 432 KB correct
7 Correct 1 ms 348 KB correct
8 Correct 0 ms 348 KB correct
9 Correct 0 ms 348 KB correct
10 Correct 1 ms 348 KB correct
11 Correct 0 ms 348 KB correct
12 Correct 1 ms 348 KB correct
13 Correct 6 ms 348 KB correct
14 Incorrect 1 ms 348 KB WA in grader: NO
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 344 KB correct
2 Correct 13 ms 348 KB correct
3 Correct 15 ms 440 KB correct
4 Correct 1 ms 348 KB correct
5 Correct 0 ms 344 KB correct
6 Correct 1 ms 432 KB correct
7 Correct 1 ms 348 KB correct
8 Correct 0 ms 348 KB correct
9 Correct 0 ms 348 KB correct
10 Correct 1 ms 348 KB correct
11 Correct 0 ms 348 KB correct
12 Correct 1 ms 348 KB correct
13 Correct 6 ms 348 KB correct
14 Incorrect 1 ms 348 KB WA in grader: NO
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB correct
2 Incorrect 0 ms 432 KB WA in grader: NO
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 344 KB correct
2 Correct 13 ms 348 KB correct
3 Correct 15 ms 440 KB correct
4 Correct 1 ms 348 KB correct
5 Correct 0 ms 344 KB correct
6 Correct 1 ms 432 KB correct
7 Correct 1 ms 348 KB correct
8 Correct 0 ms 348 KB correct
9 Correct 0 ms 348 KB correct
10 Correct 1 ms 348 KB correct
11 Correct 0 ms 348 KB correct
12 Correct 1 ms 348 KB correct
13 Correct 6 ms 348 KB correct
14 Incorrect 1 ms 348 KB WA in grader: NO
15 Halted 0 ms 0 KB -