Submission #1079025

# Submission time Handle Problem Language Result Execution time Memory
1079025 2024-08-28T09:32:06 Z Gray Simurgh (IOI17_simurgh) C++17
0 / 100
2 ms 348 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;
ll n, m;
// slow version

vector<ll> ans;

void dfs(ll u, vector<bool> &vis, vector<ll> &cur, ll lev){
	vis[u]=1;
	if (lev==n){
		ll res=count_common_roads(cur);
		// cout << e[cur[0]].ff << " ";
		// for (auto ch:cur) cout << e[ch].ss << ' ';
		// cout << " : ";
		// cout << res << ln;
		if (res==n-1) {ans=cur; return;}
	}
	for (auto i:A[u]){
		ll v = e[i].ff^e[i].ss^u;
		if (!vis[v]){
			cur.push_back(i);
			dfs(v, vis, cur, lev+1);
			cur.pop_back();
			if (ans.size()) return;
		}
	}
	vis[u]=0;
}

vector<int> find_roads(int _n, vector<int> u, vector<int> v) {
	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<bool> vis(n);
	vector<ll> cur;
	for (ll i=0; i<n and !ans.size(); i++){
		vis.assign(n, 0); cur.clear();
		dfs(i, vis, cur, 1);
	}
	assert(ans.size());
	return ans;
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB correct
2 Incorrect 2 ms 348 KB WA in grader: NO
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 344 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -