# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
466230 | 2021-08-18T11:28:17 Z | AmirElarbi | 어르신 집배원 (BOI14_postmen) | C++17 | 11 ms | 12108 KB |
#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; const int maxn = 5e5 + 5; struct edge { int fi, se; }; ve<edge> adj[maxn]; bool vis[maxn], tv[maxn]; int parent[maxn]; void dfs(int u){ if(tv[u]){ while(tv[u]){ cout << u << " "; tv[u] = 0; u = parent[u]; } cout << endl; } while(!adj[u].empty()){ edge x =adj[u].back(); adj[u].pop_back(); if(!vis[x.se]){ vis[x.se] = 1; tv[u] = 1; parent[u] = x.fi; dfs(x.fi); } } } int main(){ optimise; #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int n,m,a,b; cin >> n >> m; for (int i = 0; i < m; ++i) { cin >> a >>b; adj[a].pb({b,i}); adj[b].pb({a,i}); } dfs(1); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 11 ms | 12108 KB | Some edges were not used |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 10 ms | 12108 KB | Some edges were not used |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 10 ms | 12012 KB | Some edges were not used |
2 | Halted | 0 ms | 0 KB | - |