제출 #31533

#제출 시각아이디문제언어결과실행 시간메모리
31533minkank어르신 집배원 (BOI14_postmen)C++14
55 / 100
634 ms61392 KiB
#include <iostream>
#include <set>
#include <stack>
#include <vector>
using namespace std;

typedef pair<int, int> ii;
 
const int N = 5e5 + 5;
int n, m, st[N], p;
bool check[N], sax[N];
vector<int> s[N];
vector<ii> edge;
 
void dfs(int u) {
	while(s[u].size()) {
		int id = s[u].back(); s[u].pop_back();
		if(sax[id]) continue;
		sax[id] = true;
		int v; if(edge[id].first == u) v = edge[id].second; else v = edge[id].first;
		dfs(v);
	}
	if(check[u]) {
		while(st[p] != u) cout << st[p] << ' ', check[st[p]] = false, p--; p--;
		cout << u << '\n';		
	}
	check[u] = 1; ++p; st[p] = u;
}
 
int main() {
	scanf("%d %d", &n, &m);
	for(int i = 1; i <= m; ++i) {
		int u, v;
		scanf("%d %d", &u, &v);
		s[u].push_back(edge.size()); s[v].push_back(edge.size());
		edge.push_back(ii(u, v));
	}
	dfs(1);
}

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

postmen.cpp: In function 'void dfs(int)':
postmen.cpp:24:3: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
   while(st[p] != u) cout << st[p] << ' ', check[st[p]] = false, p--; p--;
   ^~~~~
postmen.cpp:24:70: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
   while(st[p] != u) cout << st[p] << ' ', check[st[p]] = false, p--; p--;
                                                                      ^
postmen.cpp: In function 'int main()':
postmen.cpp:31:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &m);
  ~~~~~^~~~~~~~~~~~~~~~~
postmen.cpp:34:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &u, &v);
   ~~~~~^~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...