Submission #321603

# Submission time Handle Problem Language Result Execution time Memory
321603 2020-11-12T20:43:04 Z keta_tsimakuridze Stations (IOI20_stations) C++14
100 / 100
1045 ms 1332 KB
#include <cstdio>
#include "stations.h"
#include <vector>
#include<bits/stdc++.h>
using namespace std;
const int N=1005;
int fix[N],timer;
 vector<int> V[N],labels;
void dfs(int u,int h){
	fix[u]=1;
	
	if(h%2==0) timer++,labels[u]=timer;
	for(int i=0;i<V[u].size();i++){
		if(!fix[V[u][i]]){
			dfs(V[u][i],h+1);
		}
	}
	if(h%2) timer++,labels[u]=timer;//cout<<u<<"__"<<labels[u]<<endl;
}
 
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	labels.clear();
	labels.resize(n);
	for(int i=0;i<n;i++)
	V[i].clear(),fix[i]=0;
	for (int i = 0; i < u.size(); i++) {
		V[u[i]].push_back(v[i]);
		V[v[i]].push_back(u[i]);
	} timer=0;
	for(int i=0;i<n;i++){
		if(!fix[i]){
			dfs(i,0);
		}
	}
	return labels;
}
 
int find_next_station(int s, int t, std::vector<int> c) {
//	cout<<"++";
	if(s<c[0]) {
		//inia es
	    if(t>s){	
			for(int i=0;i<c.size()-1;i++){
				if(t<=c[i]) return c[i];
			}
		}
		return c[c.size()-1];			
	}
	else {
		if(t<s){
			for(int i=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, int)':
stations.cpp:13:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |  for(int i=0;i<V[u].size();i++){
      |              ~^~~~~~~~~~~~
stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:26:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |  for (int i = 0; i < u.size(); i++) {
      |                  ~~^~~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:43:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |    for(int i=0;i<c.size()-1;i++){
      |                ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 663 ms 1088 KB Output is correct
2 Correct 481 ms 1084 KB Output is correct
3 Correct 953 ms 1076 KB Output is correct
4 Correct 644 ms 956 KB Output is correct
5 Correct 552 ms 948 KB Output is correct
6 Correct 429 ms 1092 KB Output is correct
7 Correct 517 ms 1120 KB Output is correct
8 Correct 3 ms 864 KB Output is correct
9 Correct 5 ms 736 KB Output is correct
10 Correct 1 ms 864 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 526 ms 736 KB Output is correct
2 Correct 522 ms 1120 KB Output is correct
3 Correct 926 ms 948 KB Output is correct
4 Correct 688 ms 1024 KB Output is correct
5 Correct 687 ms 1332 KB Output is correct
6 Correct 491 ms 896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 536 ms 1080 KB Output is correct
2 Correct 466 ms 1084 KB Output is correct
3 Correct 915 ms 948 KB Output is correct
4 Correct 697 ms 1120 KB Output is correct
5 Correct 662 ms 736 KB Output is correct
6 Correct 462 ms 992 KB Output is correct
7 Correct 512 ms 1056 KB Output is correct
8 Correct 3 ms 1120 KB Output is correct
9 Correct 4 ms 956 KB Output is correct
10 Correct 1 ms 736 KB Output is correct
11 Correct 584 ms 736 KB Output is correct
12 Correct 457 ms 1248 KB Output is correct
13 Correct 411 ms 1184 KB Output is correct
14 Correct 438 ms 1024 KB Output is correct
15 Correct 49 ms 948 KB Output is correct
16 Correct 63 ms 736 KB Output is correct
17 Correct 112 ms 880 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 804 ms 948 KB Output is correct
2 Correct 629 ms 948 KB Output is correct
3 Correct 562 ms 948 KB Output is correct
4 Correct 3 ms 736 KB Output is correct
5 Correct 5 ms 992 KB Output is correct
6 Correct 2 ms 864 KB Output is correct
7 Correct 660 ms 1164 KB Output is correct
8 Correct 1045 ms 948 KB Output is correct
9 Correct 764 ms 864 KB Output is correct
10 Correct 577 ms 864 KB Output is correct
11 Correct 6 ms 864 KB Output is correct
12 Correct 7 ms 864 KB Output is correct
13 Correct 6 ms 736 KB Output is correct
14 Correct 4 ms 956 KB Output is correct
15 Correct 2 ms 864 KB Output is correct
16 Correct 513 ms 992 KB Output is correct
17 Correct 551 ms 956 KB Output is correct
18 Correct 553 ms 1120 KB Output is correct
19 Correct 488 ms 992 KB Output is correct
20 Correct 478 ms 736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 528 ms 992 KB Output is correct
2 Correct 447 ms 864 KB Output is correct
3 Correct 968 ms 948 KB Output is correct
4 Correct 659 ms 1076 KB Output is correct
5 Correct 674 ms 948 KB Output is correct
6 Correct 448 ms 1248 KB Output is correct
7 Correct 573 ms 868 KB Output is correct
8 Correct 3 ms 956 KB Output is correct
9 Correct 5 ms 864 KB Output is correct
10 Correct 2 ms 864 KB Output is correct
11 Correct 523 ms 736 KB Output is correct
12 Correct 667 ms 896 KB Output is correct
13 Correct 848 ms 864 KB Output is correct
14 Correct 624 ms 956 KB Output is correct
15 Correct 609 ms 956 KB Output is correct
16 Correct 445 ms 896 KB Output is correct
17 Correct 569 ms 864 KB Output is correct
18 Correct 469 ms 1108 KB Output is correct
19 Correct 482 ms 992 KB Output is correct
20 Correct 453 ms 896 KB Output is correct
21 Correct 68 ms 948 KB Output is correct
22 Correct 83 ms 736 KB Output is correct
23 Correct 138 ms 736 KB Output is correct
24 Correct 6 ms 896 KB Output is correct
25 Correct 7 ms 736 KB Output is correct
26 Correct 4 ms 948 KB Output is correct
27 Correct 4 ms 864 KB Output is correct
28 Correct 2 ms 956 KB Output is correct
29 Correct 542 ms 736 KB Output is correct
30 Correct 474 ms 864 KB Output is correct
31 Correct 515 ms 864 KB Output is correct
32 Correct 508 ms 884 KB Output is correct
33 Correct 539 ms 1040 KB Output is correct
34 Correct 279 ms 1100 KB Output is correct
35 Correct 421 ms 1120 KB Output is correct
36 Correct 551 ms 1088 KB Output is correct
37 Correct 448 ms 1108 KB Output is correct
38 Correct 534 ms 1148 KB Output is correct
39 Correct 457 ms 1248 KB Output is correct
40 Correct 491 ms 1136 KB Output is correct
41 Correct 431 ms 980 KB Output is correct
42 Correct 76 ms 892 KB Output is correct
43 Correct 153 ms 864 KB Output is correct
44 Correct 120 ms 1044 KB Output is correct
45 Correct 170 ms 992 KB Output is correct
46 Correct 315 ms 892 KB Output is correct
47 Correct 342 ms 864 KB Output is correct
48 Correct 62 ms 1088 KB Output is correct
49 Correct 63 ms 1120 KB Output is correct