제출 #292209

#제출 시각아이디문제언어결과실행 시간메모리
292209davooddkareshki어르신 집배원 (BOI14_postmen)C++17
55 / 100
1014 ms58732 KiB
#include<bits/stdc++.h> using namespace std; //#define int long long #define F first #define S second #define pii pair<int,int> #define mpr make_pair typedef long long ll; const int maxn = 5e5+1; const int mod = 1e9+7; int n, m, k; bitset<maxn> mark_E; vector<pii> g[maxn]; int ptr[maxn]; bitset<maxn> mark; vector<int> stk; void DO(int v) { if(mark[v]) { while(stk.back() != v) { int u = stk.back(); mark[u] = 0; cout<< u <<" "; //printf("%d ", u); stk.pop_back(); } mark[v] = 0; cout<< v <<"\n"; // printf("%d\n", v); stk.pop_back(); } mark[v] = 1; stk.push_back(v); } void dfs(int v) { for(; ptr[v] < g[v].size(); ptr[v]++) { pii e = g[v][ptr[v]]; int u = e.F, id = e.S; if(!mark_E[id]) { mark_E[id] = 1; dfs(u); DO(u); } } } signed main() { //ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); // scanf("%d%d", &n, &m); cin>> n >> m; for(int i = 1, u, v; i <= m; i++) { //scanf("%d%d", &u, &v); cin>> u >> v; g[u].push_back({v,i}); g[v].push_back({u,i}); } dfs(1); DO(1); } /* 10 15 1 3 5 1 2 3 9 2 3 4 6 3 4 5 7 4 4 8 5 7 8 5 6 7 7 8 8 10 10 9 */

컴파일 시 표준 에러 (stderr) 메시지

postmen.cpp: In function 'void dfs(int)':
postmen.cpp:46:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |     for(; ptr[v] < g[v].size(); ptr[v]++)
      |           ~~~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...