Submission #11145

#TimeUsernameProblemLanguageResultExecution timeMemory
11145tncks0121Senior Postmen (BOI14_postmen)C++14
38 / 100
957 ms31360 KiB
// // main.cpp // BOI14_postmen // // Created by 박수찬 on 14. 11. 14.. // Copyright (c) 2014년 박수찬. All rights reserved. // #include <stdio.h> #include <stdlib.h> #include <string.h> #include <memory.h> #include <math.h> #include <assert.h> #include <stack> #include <queue> #include <map> #include <set> #include <algorithm> #include <string> #include <functional> #include <vector> #include <numeric> #include <deque> #include <utility> #include <bitset> #include <limits.h> #include <iostream> using namespace std; typedef long long ll; typedef unsigned long long llu; typedef double lf; typedef unsigned int uint; typedef long double llf; typedef pair<int, int> pii; const int N_ = 500050, M_ = 500050; int N, M; vector<int> gph[N_]; vector<int> edge[N_]; bool passed[M_]; bool visited[N_]; int main() { scanf("%d%d", &N, &M); for(int i = 1; i <= M; i++) { int u, v; scanf("%d%d", &u, &v); gph[u].push_back(v); gph[v].push_back(u); edge[u].push_back(i); edge[v].push_back(i); } for(int u = 1; u <= N; u++) { stack<int> stk; stk.push(u); while(!stk.empty()) { int cur = stk.top(); visited[cur] = true; bool updated = false; for(int i = 0; i < gph[cur].size(); i++) { int nxt = gph[cur][i]; int e = edge[cur][i]; if(passed[e]) continue; passed[e] = true; if(visited[nxt]) { while(!stk.empty() && stk.top() != nxt) { int vt = stk.top(); stk.pop(); visited[vt] = false; printf("%d ", vt); } printf("%d\n", nxt); } else { stk.push(nxt); } updated = true; break; } if(!updated && !stk.empty()) stk.pop(); } } return 0; }

Compilation message (stderr)

postmen.cpp: In function 'int main()':
postmen.cpp:64:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(int i = 0; i < gph[cur].size(); i++) {
                            ~~^~~~~~~~~~~~~~~~~
postmen.cpp:47: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:49:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         int u, v; scanf("%d%d", &u, &v);
                   ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...