Submission #428973

#TimeUsernameProblemLanguageResultExecution timeMemory
428973Dremix10Simurgh (IOI17_simurgh)C++17
0 / 100
3054 ms7360 KiB
#include "simurgh.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pi; typedef pair<ll,ll> pl; #define endl '\n' #define F first #define S second #define all(x) (x).begin(),(x).end() const int N = 3e5+1; const ll INF = 2e18; const int MOD = 1e9+7; vector<vector<pi> > a(N); bool vs[N],idx[N]; int cnt; void dfs(int s){ cnt++; vs[s] = true; for(auto x : a[s]) if(!vs[x.F] && idx[x.S]) dfs(x.F); } int mm,nn; vector<int> ans; void solve(int curr){ if(curr == nn-1){ cnt = 0; dfs(0); for(int i=0;i<nn;i++) vs[i] = false; vector<int> arr; for(int i=0;i<mm;i++) if(idx[i]){ arr.push_back(i); //cout<<i<<" "; }//cout<<endl; //cout<<cnt<<endl; if(cnt != nn)return; if(count_common_roads(arr) == nn-1){ ans = arr; return; } } for(int i=0;i<mm;i++){ if(idx[i])continue; idx[i] = true; solve(curr+1); idx[i] = false; } } vector<int> find_roads(int n, vector<int> u, vector<int> v) { int i,j; mm = u.size(); nn = n; for(i=0;i<mm;i++){ int x = u[i]; int y = v[i]; a[x].push_back({y,i}); a[y].push_back({x,i}); } solve(0); return ans; }

Compilation message (stderr)

simurgh.cpp: In function 'std::vector<int> find_roads(int, std::vector<int>, std::vector<int>)':
simurgh.cpp:60:11: warning: unused variable 'j' [-Wunused-variable]
   60 |     int i,j;
      |           ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...