# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
115963 | 2019-06-10T04:59:45 Z | Mahdi_Jfri | 어르신 집배원 (BOI14_postmen) | C++14 | 151 ms | 262148 KB |
#include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back const int maxn = 5e5 + 20; vector<int> path; stack<int> adj[maxn]; int from[maxn] , to[maxn]; bool visited[maxn]; void dfs(int v) { while(!adj[v].empty()) { int e = adj[v].top() , u = from[e] ^ to[e] ^ v; adj[v].pop(); if(visited[e]) continue; visited[e] = 1; dfs(u); } path.pb(v); } int main() { int n , m; scanf("%d%d", &n, &m); for(int i = 0; i < m; i++) { int a , b; scanf("%d%d", &a, &b); a-- , b--; adj[a].push(i); adj[b].push(i); from[i] = a , to[i] = b; } path.reserve(1 << 20); dfs(0); vector<int> tmp; tmp.reserve(1 << 20); memset(visited , 0 , sizeof visited); for(auto v : path) { if(visited[v]) { while(tmp.back() != v) { printf("%d ", tmp.back() + 1); visited[tmp.back()] = 0; tmp.pop_back(); } tmp.pop_back(); printf("%d\n", v + 1); } tmp.pb(v); visited[v] = 1; } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 143 ms | 262148 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 139 ms | 262148 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 151 ms | 262148 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |