Submission #227173

# Submission time Handle Problem Language Result Execution time Memory
227173 2020-04-26T10:02:59 Z tushar_2658 Senior Postmen (BOI14_postmen) C++14
0 / 100
20 ms 23808 KB
#include "bits/stdc++.h"
using namespace std;

const int maxn = 500005;
multiset<int> edges[maxn];
vector<int> path;

void dfs(int x){
	while(!edges[x].empty()){
		int i = *edges[x].begin();
		edges[x].erase(edges[x].find(i));
		edges[i].erase(edges[i].find(x));
		dfs(i);
	}
	path.push_back(x);
}

int main(int argc, char const *argv[])
{
//	freopen("in.txt", "r", stdin); 
	int n, m;
	scanf("%d %d", &n, &m); 
	for(int i = 0; i < m; ++i){
		int x, y;
		scanf("%d %d", &x, &y); 
		edges[x].insert(y); 
		edges[y].insert(x);
	}
	dfs(1);
	path.pop_back();
	vector<vector<int>> ans;
	while(!path.empty()){
		vector<int> v;
		v.push_back(path.back());
		int st = path.back();
		path.pop_back();
		while(!path.empty() && path.back() != st){
			v.push_back(path.back());
			path.pop_back();
		}
		ans.push_back(v);
	}
	for(auto i : ans){
		for(auto j : i){
			printf("%d ", j);
		}
		printf("\n");
	}

	return 0;
}

Compilation message

postmen.cpp: In function 'int main(int, const char**)':
postmen.cpp:22: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:25:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &x, &y); 
   ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 18 ms 23808 KB Output is correct
2 Incorrect 17 ms 23808 KB Same junction appears twice in a route
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 18 ms 23808 KB Output is correct
2 Incorrect 18 ms 23808 KB Same junction appears twice in a route
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 18 ms 23808 KB Output is correct
2 Incorrect 20 ms 23808 KB Same junction appears twice in a route
3 Halted 0 ms 0 KB -