Submission #322068

# Submission time Handle Problem Language Result Execution time Memory
322068 2020-11-14T01:57:18 Z gurkot Stations (IOI20_stations) C++14
0 / 100
830 ms 1232 KB
#include "stations.h"
#include <vector>
#include <iostream> 
using namespace std;
 
int fix[1000],lab[1000],timer,lev;
vector <int> gr[1000];
 
void dfs(int u){ 
 
 fix[u]=1; lev++;
 if((lev&1)==0) lab[u]=timer++;    
 
    
 for(int i=0;i<gr[u].size();i++)
   if(fix[gr[u][i]]==0) dfs(gr[u][i]);		
	
 if((lev&1)==1) lab[u]=timer++;
 lev--;	
}
 
vector<int> label(int n, int k, vector<int> u, vector<int> v) {
 vector <int> labels; labels.resize(n);
 
 for(int i=0;i<n;i++) {
  gr[i].clear();  lab[i]=fix[i]=0;
 }
	
 for (int i=0; i<(int)u.size(); i++) {
  gr[u[i]].push_back(v[i]);
  gr[v[i]].push_back(u[i]);
 }  

 timer=0; lev=-1;
 dfs(0);
 for(int i=0;i<n;i++)   labels[i]=lab[i]; 
 
 return labels;
}
 
int find_next_station(int s, int t, vector<int> c) {
 if(s<c[0]) {
  if(t>s)	
   for(int i=0;i<(int)c.size()-1;i++)
	if(t<=c[i]) return c[i];	
		
   return c[c.size()-1];			
 } else {
  for(int i=(int)c.size()-1;i>=1;i--)
   if(t>=c[i]) return c[i];
	
  return c[0];
 }
}

Compilation message

stations.cpp: In function 'void dfs(int)':
stations.cpp:15:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |  for(int i=0;i<gr[u].size();i++)
      |              ~^~~~~~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:43:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   43 |   if(t>s)
      |   ^~
stations.cpp:47:4: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   47 |    return c[c.size()-1];
      |    ^~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 543 ms 1232 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 445 ms 1008 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 522 ms 1120 KB Wrong query response.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 827 ms 896 KB Output is correct
2 Correct 830 ms 992 KB Output is correct
3 Incorrect 762 ms 944 KB Wrong query response.
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 559 ms 1104 KB Wrong query response.
2 Halted 0 ms 0 KB -