Submission #39890

# Submission time Handle Problem Language Result Execution time Memory
39890 2018-01-23T14:42:06 Z Lkvatashidze Senior Postmen (BOI14_postmen) C++14
0 / 100
6 ms 384 KB
#include <bits/stdc++.h>
using namespace std;
     
      int n, m;
      int g[2005][2005];
      vector < int > ans;
      
   /*   void DFS (int v) {

      	  set < int >  ::iterator st_it;
      	 for (st_it=g[v].begin(); st_it!=g[v].end(); st_it++) {
      	 	 int p=(*st_it);
		   	g[v].erase(p);
			g[p].erase(v); 
				ans.push_back(v);
		      DFS(p);
      	}
      	  for (int k=0; k<ans.size(); k++) {
	  cout << ans[k] << ' ';
	   exit(0);
}
    
 } */
 
  void DFS (int v) {
  	 for (int k=1; k<=n; k++) 
  	  if (g[k][v]>0) {
  	  	g[k][v]--;
  	  	g[v][k]--;
  	  	DFS(k);
		}
		
		ans.push_back(v);
  }
       
  int main () {
  	
      ios::sync_with_stdio(false);
	  cin.tie(0);

		  
	   cin >> n >> m;
	   
		    
	  for (int k=1; k<=m; k++) {
	  	 int x, y;
	  	  cin >> x >> y;
	  //	  g[x].insert(y);
	  //	  g[y].insert(x);
	     g[x][y]++;
	     g[y][x]++;
	  }  	
  	  
  	  DFS(1);
	
	 for (int k=0; k<ans.size()-1; k++)
	  cout << ans[k] << ' ';
	
  	return 0;
}

Compilation message

postmen.cpp: In function 'int main()':
postmen.cpp:56:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int k=0; k<ans.size()-1; k++)
                 ~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 6 ms 384 KB Output is correct
2 Incorrect 5 ms 304 KB Same junction appears twice in a route
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 5 ms 384 KB Same junction appears twice in a route
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 360 KB Output is correct
2 Incorrect 5 ms 384 KB Same junction appears twice in a route
3 Halted 0 ms 0 KB -