Submission #322073

# Submission time Handle Problem Language Result Execution time Memory
322073 2020-11-14T02:28:45 Z gurkot Stations (IOI20_stations) C++14
100 / 100
1136 ms 1136 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<(int)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]){
  c.insert(c.begin(),s);
  for(int i=1; i<(int)c.size()-1; i++)
	if(t<=c[i] && t>=c[i-1]+1) return c[i];			
  return c[c.size()-1];
 } else {
  c.push_back(s);
  for(int i=1; i<c.size()-1; i++)
   if(t>=c[i] && t<=c[i+1]-1) return c[i];		
  return c[0];
 }
}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:49:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |   for(int i=1; i<c.size()-1; i++)
      |                ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 571 ms 992 KB Output is correct
2 Correct 457 ms 992 KB Output is correct
3 Correct 866 ms 944 KB Output is correct
4 Correct 610 ms 896 KB Output is correct
5 Correct 585 ms 944 KB Output is correct
6 Correct 545 ms 1108 KB Output is correct
7 Correct 567 ms 864 KB Output is correct
8 Correct 3 ms 816 KB Output is correct
9 Correct 4 ms 736 KB Output is correct
10 Correct 1 ms 736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 476 ms 864 KB Output is correct
2 Correct 544 ms 1016 KB Output is correct
3 Correct 1132 ms 736 KB Output is correct
4 Correct 883 ms 944 KB Output is correct
5 Correct 564 ms 944 KB Output is correct
6 Correct 452 ms 896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 601 ms 1108 KB Output is correct
2 Correct 558 ms 1012 KB Output is correct
3 Correct 878 ms 824 KB Output is correct
4 Correct 797 ms 864 KB Output is correct
5 Correct 706 ms 864 KB Output is correct
6 Correct 443 ms 1120 KB Output is correct
7 Correct 506 ms 864 KB Output is correct
8 Correct 3 ms 944 KB Output is correct
9 Correct 5 ms 864 KB Output is correct
10 Correct 2 ms 864 KB Output is correct
11 Correct 724 ms 896 KB Output is correct
12 Correct 470 ms 1120 KB Output is correct
13 Correct 535 ms 992 KB Output is correct
14 Correct 416 ms 896 KB Output is correct
15 Correct 66 ms 864 KB Output is correct
16 Correct 79 ms 736 KB Output is correct
17 Correct 123 ms 864 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 972 ms 944 KB Output is correct
2 Correct 695 ms 864 KB Output is correct
3 Correct 627 ms 864 KB Output is correct
4 Correct 3 ms 944 KB Output is correct
5 Correct 6 ms 864 KB Output is correct
6 Correct 2 ms 864 KB Output is correct
7 Correct 683 ms 944 KB Output is correct
8 Correct 941 ms 768 KB Output is correct
9 Correct 803 ms 736 KB Output is correct
10 Correct 594 ms 864 KB Output is correct
11 Correct 7 ms 984 KB Output is correct
12 Correct 5 ms 736 KB Output is correct
13 Correct 6 ms 952 KB Output is correct
14 Correct 5 ms 736 KB Output is correct
15 Correct 2 ms 736 KB Output is correct
16 Correct 571 ms 864 KB Output is correct
17 Correct 574 ms 864 KB Output is correct
18 Correct 538 ms 836 KB Output is correct
19 Correct 610 ms 736 KB Output is correct
20 Correct 636 ms 944 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 543 ms 1104 KB Output is correct
2 Correct 516 ms 864 KB Output is correct
3 Correct 1136 ms 944 KB Output is correct
4 Correct 788 ms 736 KB Output is correct
5 Correct 615 ms 944 KB Output is correct
6 Correct 470 ms 864 KB Output is correct
7 Correct 476 ms 876 KB Output is correct
8 Correct 3 ms 992 KB Output is correct
9 Correct 5 ms 864 KB Output is correct
10 Correct 2 ms 952 KB Output is correct
11 Correct 480 ms 864 KB Output is correct
12 Correct 578 ms 1104 KB Output is correct
13 Correct 848 ms 944 KB Output is correct
14 Correct 701 ms 864 KB Output is correct
15 Correct 551 ms 944 KB Output is correct
16 Correct 441 ms 864 KB Output is correct
17 Correct 645 ms 864 KB Output is correct
18 Correct 514 ms 1120 KB Output is correct
19 Correct 530 ms 1008 KB Output is correct
20 Correct 486 ms 864 KB Output is correct
21 Correct 73 ms 864 KB Output is correct
22 Correct 92 ms 864 KB Output is correct
23 Correct 133 ms 880 KB Output is correct
24 Correct 6 ms 864 KB Output is correct
25 Correct 6 ms 992 KB Output is correct
26 Correct 6 ms 864 KB Output is correct
27 Correct 5 ms 736 KB Output is correct
28 Correct 2 ms 864 KB Output is correct
29 Correct 572 ms 864 KB Output is correct
30 Correct 534 ms 864 KB Output is correct
31 Correct 500 ms 736 KB Output is correct
32 Correct 541 ms 864 KB Output is correct
33 Correct 575 ms 864 KB Output is correct
34 Correct 329 ms 992 KB Output is correct
35 Correct 425 ms 1108 KB Output is correct
36 Correct 489 ms 1008 KB Output is correct
37 Correct 660 ms 1012 KB Output is correct
38 Correct 468 ms 1008 KB Output is correct
39 Correct 480 ms 1016 KB Output is correct
40 Correct 456 ms 1136 KB Output is correct
41 Correct 522 ms 896 KB Output is correct
42 Correct 61 ms 864 KB Output is correct
43 Correct 101 ms 952 KB Output is correct
44 Correct 156 ms 864 KB Output is correct
45 Correct 179 ms 1120 KB Output is correct
46 Correct 303 ms 992 KB Output is correct
47 Correct 306 ms 884 KB Output is correct
48 Correct 70 ms 1088 KB Output is correct
49 Correct 75 ms 1052 KB Output is correct