Submission #465770

#TimeUsernameProblemLanguageResultExecution timeMemory
465770AmirElarbiSenior Postmen (BOI14_postmen)C++14
0 / 100
6 ms2960 KiB
#include <bits/stdc++.h> #define vi vector<int> #define ve vector #define ll long long #define vf vector<float> #define vll vector<pair<ll,ll>> #define ii pair<int,int> #define vvi vector<vi> #define vii vector<ii> #define gii greater<ii> #define pb push_back #define fi first #define se second #define INF 1e7 #define unsigned u #define eps 1e-18 #define eps1 1e-25 #define optimise ios_base::sync_with_stdio(false);cin.tie(NULL); #define MAX_A 100005 #define V 450 #define re register #define maxi(a,b) ((a) > (b) ? (a) : (b)) using namespace std; vii adj[100005]; bool vis[100005]; int tv[100005]; int n,m,used, tours = 1; bool dfs(int u, int p, int start){ //cout << u << " " << start << " " << used << " " << tours << endl; tv[u]++; for(auto x : adj[u]) { if(x.fi == p) continue; if(vis[x.se]) continue; if(x.fi == start) { vis[x.se] = true; used++; if(used == m) return true; for (int i = 1; i <= n; ++i) { //cout << i << endl; tours++; if(dfs(i,-1,i)){ cout << i << endl; return true; } tours--; } vis[x.se] = 0; used--; return false; } if(tv[x.fi] >= tours) continue; vis[x.se] = true; used++; if(dfs(x.fi,u,start)){ cout << x.fi << " "; return true; } vis[x.se] = 0; used--; } return false; } int main(){ optimise; cin >> n >> m; for (int i = 0; i < m; ++i) { int a,b; cin >> a >>b; adj[a].pb({b,i}); adj[b].pb({a,i}); } if(dfs(1,-1,1)){ cout << 1; return 0; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...