# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
11213 | gs14004 | 어르신 집배원 (BOI14_postmen) | C++98 | 666 ms | 94176 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <cstdio>
#include <vector>
#include <cstring>
#include <set>
using namespace std;
set<int> graph[500005];
int n,m;
vector<int> cyc, temp;
void f(int x){
set<int> ::iterator it;
while (graph[x].size()) {
it = graph[x].begin();
int pos = *it;
graph[x].erase(it);
graph[pos].erase(graph[pos].find(x));
f(pos);
}
cyc.push_back(x);
}
int vis[500005];
int main(){
scanf("%d %d",&n,&m);
for (int i=0; i<m; i++) {
int s,e;
scanf("%d %d",&s,&e);
graph[s].insert(e);
graph[e].insert(s);
}
f(1);
for (int i=0; i<cyc.size(); i++) {
temp.push_back(cyc[i]);
if(vis[cyc[i]]){
printf("%d ",temp.back());
temp.pop_back();
while(temp.back() != cyc[i]){
printf("%d ",temp.back());
vis[temp.back()] = 0;
temp.pop_back();
}
puts("");
}
else vis[cyc[i]] = 1;
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |