답안 #321605

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
321605 2020-11-12T20:47:42 Z keta_tsimakuridze 기지국 (IOI20_stations) C++14
100 / 100
960 ms 1408 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;
}
 
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) {
	if(s<c[0]) {
	    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:12:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |  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:25:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |  for (int i = 0; i < u.size(); i++) {
      |                  ~~^~~~~~~~~~
stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:40:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |    for(int i=0;i<c.size()-1;i++){
      |                ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 561 ms 1088 KB Output is correct
2 Correct 468 ms 1092 KB Output is correct
3 Correct 883 ms 864 KB Output is correct
4 Correct 732 ms 1204 KB Output is correct
5 Correct 673 ms 948 KB Output is correct
6 Correct 436 ms 1092 KB Output is correct
7 Correct 547 ms 1112 KB Output is correct
8 Correct 3 ms 1024 KB Output is correct
9 Correct 4 ms 864 KB Output is correct
10 Correct 1 ms 736 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 449 ms 1036 KB Output is correct
2 Correct 501 ms 864 KB Output is correct
3 Correct 846 ms 736 KB Output is correct
4 Correct 646 ms 736 KB Output is correct
5 Correct 528 ms 864 KB Output is correct
6 Correct 444 ms 736 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 508 ms 1024 KB Output is correct
2 Correct 429 ms 1084 KB Output is correct
3 Correct 809 ms 864 KB Output is correct
4 Correct 635 ms 896 KB Output is correct
5 Correct 550 ms 948 KB Output is correct
6 Correct 429 ms 1248 KB Output is correct
7 Correct 486 ms 1244 KB Output is correct
8 Correct 3 ms 736 KB Output is correct
9 Correct 5 ms 736 KB Output is correct
10 Correct 1 ms 736 KB Output is correct
11 Correct 597 ms 1012 KB Output is correct
12 Correct 519 ms 1084 KB Output is correct
13 Correct 447 ms 992 KB Output is correct
14 Correct 531 ms 1408 KB Output is correct
15 Correct 59 ms 736 KB Output is correct
16 Correct 67 ms 864 KB Output is correct
17 Correct 110 ms 864 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 914 ms 948 KB Output is correct
2 Correct 871 ms 864 KB Output is correct
3 Correct 655 ms 1120 KB Output is correct
4 Correct 3 ms 1076 KB Output is correct
5 Correct 5 ms 864 KB Output is correct
6 Correct 1 ms 736 KB Output is correct
7 Correct 566 ms 864 KB Output is correct
8 Correct 843 ms 864 KB Output is correct
9 Correct 778 ms 864 KB Output is correct
10 Correct 638 ms 1076 KB Output is correct
11 Correct 6 ms 956 KB Output is correct
12 Correct 7 ms 736 KB Output is correct
13 Correct 5 ms 956 KB Output is correct
14 Correct 3 ms 988 KB Output is correct
15 Correct 2 ms 864 KB Output is correct
16 Correct 546 ms 864 KB Output is correct
17 Correct 442 ms 840 KB Output is correct
18 Correct 521 ms 864 KB Output is correct
19 Correct 576 ms 948 KB Output is correct
20 Correct 486 ms 864 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 507 ms 1016 KB Output is correct
2 Correct 455 ms 1088 KB Output is correct
3 Correct 865 ms 948 KB Output is correct
4 Correct 693 ms 956 KB Output is correct
5 Correct 630 ms 956 KB Output is correct
6 Correct 502 ms 1096 KB Output is correct
7 Correct 425 ms 864 KB Output is correct
8 Correct 3 ms 736 KB Output is correct
9 Correct 5 ms 992 KB Output is correct
10 Correct 2 ms 736 KB Output is correct
11 Correct 557 ms 1100 KB Output is correct
12 Correct 556 ms 896 KB Output is correct
13 Correct 960 ms 948 KB Output is correct
14 Correct 658 ms 864 KB Output is correct
15 Correct 650 ms 896 KB Output is correct
16 Correct 517 ms 904 KB Output is correct
17 Correct 638 ms 948 KB Output is correct
18 Correct 494 ms 1236 KB Output is correct
19 Correct 495 ms 1216 KB Output is correct
20 Correct 439 ms 864 KB Output is correct
21 Correct 59 ms 948 KB Output is correct
22 Correct 74 ms 736 KB Output is correct
23 Correct 130 ms 736 KB Output is correct
24 Correct 6 ms 956 KB Output is correct
25 Correct 7 ms 956 KB Output is correct
26 Correct 5 ms 736 KB Output is correct
27 Correct 4 ms 956 KB Output is correct
28 Correct 2 ms 736 KB Output is correct
29 Correct 484 ms 1012 KB Output is correct
30 Correct 513 ms 948 KB Output is correct
31 Correct 528 ms 736 KB Output is correct
32 Correct 551 ms 948 KB Output is correct
33 Correct 651 ms 864 KB Output is correct
34 Correct 402 ms 1092 KB Output is correct
35 Correct 460 ms 992 KB Output is correct
36 Correct 477 ms 1292 KB Output is correct
37 Correct 496 ms 1108 KB Output is correct
38 Correct 510 ms 1236 KB Output is correct
39 Correct 450 ms 1236 KB Output is correct
40 Correct 554 ms 1256 KB Output is correct
41 Correct 478 ms 1120 KB Output is correct
42 Correct 64 ms 904 KB Output is correct
43 Correct 119 ms 992 KB Output is correct
44 Correct 134 ms 872 KB Output is correct
45 Correct 196 ms 992 KB Output is correct
46 Correct 320 ms 892 KB Output is correct
47 Correct 383 ms 984 KB Output is correct
48 Correct 71 ms 1096 KB Output is correct
49 Correct 62 ms 1084 KB Output is correct