이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
#include <utility>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#define MAXN 500005
using namespace std;
int N, M, del[MAXN], inStack[MAXN];
vector <pair<int,int> > adj[MAXN];
vector <int> S,S2;
void dfs(int u) { //Hierholzer
while (adj[u].size()) {
int v = adj[u].back().first, id = adj[u].back().second;
adj[u].pop_back();
if (!del[id]) {
del[id] = true;
dfs(v);
}
}
S.push_back(u);
}
int main() {
//freopen("seniorin.txt","r",stdin);
scanf("%d %d",&N,&M);
for (int i=1; i<=M; i++) {
int u,v;
scanf("%d %d",&u,&v);
adj[u].push_back({v,i});
adj[v].push_back({u,i});
}
dfs(1);
for (int i=0; i<S.size(); i++) {
if (inStack[S[i]]) {
while (S2.size() && S2.back() != S[i]) {
printf("%d ",S2.back());
inStack[S2.back()]--;
S2.pop_back();
}
printf("%d\n",S[i]);
} else {
inStack[S[i]]++;
S2.push_back(S[i]);
}
}
}
컴파일 시 표준 에러 (stderr) 메시지
postmen.cpp: In function 'int main()':
postmen.cpp:35:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i=0; i<S.size(); i++) {
~^~~~~~~~~
postmen.cpp:27:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d",&N,&M);
~~~~~^~~~~~~~~~~~~~~
postmen.cpp:30:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d %d",&u,&v);
~~~~~^~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |