답안 #431929

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
431929 2021-06-17T17:28:20 Z gonengazit 기지국 (IOI20_stations) C++14
52.3205 / 100
922 ms 824 KB
#include "stations.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
#define ii pair<int,int>
#define x first
#define y second
vector<int> labels;
vector<vector<int>> g;
int tme;
// void dfs1(int i,int f=0,int t=0, int s=0){
// 	int tin=++tme;
// 	for(auto u:g[i]){
// 		if(u!=f){
// 			dfs1(u,i,(t+1)%2,(s+1)%3);
// 		}
// 	}
// 	int tout=tme;
// 	if(t==0){
// 		labels[i]=6*tin+3*t+s;
// 	}
// 	else{
// 		labels[i]=6*(tin+tout)+3*t+s;
// 	}
// }

void dfs1(int i, int f=0){
	int tin=++tme;
	for(auto u:g[i]){
		if(u!=f){
			dfs1(u,i);
		}
	}
	int tout=tme;
	labels[i]=tin*1000+tout;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	tme=-1;
	labels.assign(n,-1);
	g.assign(n,vector<int>());
	for(int i=0; i<n-1; i++){
		g[u[i]].push_back(v[i]);
		g[v[i]].push_back(u[i]);
	}
	dfs1(0);
	return labels;
}

ii get(int x){
	return ii(x/3%2,x%3);
}
int find_next_station(int s, int t, std::vector<int> c) {
	int tin=t/1000;
	int tout=t%1000;

	int sin=s/1000;
	int sout=s%1000;

	int f;
	for(auto i:c){
		int in=i/1000;
		int out=i%1000;
		if(in<sin){
			f=i;
			continue;
		}
		if (tin>=in&&tout<=out){
			return i;
		}
	}
	return f;
	// ii r=get(s);
	// s/=6;
	// vector<pair<ii,int>> cld;
	// int f=-1;
	// if(r.x==0){
	// 	int prev=s;
	// 	for(auto i:c){
	// 		if(get(i).y!=(r.y+1)%3){
	// 			f=i;
	// 			continue;
	// 		}
	// 		int k=i/6;
	// 		cld.emplace_back(ii(prev+1,k-(prev+1)),i);
	// 		prev=k-(prev+1);
	// 	}
	// }
	// else{
	// 	for(auto i:c){
	// 		if(get(i).y!=(r.y+1)%3){
	// 			f=i;
	// 			continue;
	// 		}
	// 		if(!cld.empty())
	// 			cld.back().x.y=i/6-1;
	// 		cld.emplace_back(ii(i/6,-1),i);
	// 	}
	// 	if(!cld.empty()){
	// 		cld.back().x.y=s-(cld[0].x.x-1);
	// 	}
	// }

	// ii h=get(t);
	// t/=6;

	// for(auto i:cld){
	// 	if(h.x==0&&i.x.x<=t&&i.x.y>=t){
	// 		return i.y;
	// 	}
	// 	else if(h.x==1&&2*i.x.x<=t&&2*i.x.y>=t){
	// 		return i.y;
	// 	}
	// }
	// return f;
}
/*
1
5 100
0 1
1 2
1 3
2 4
3
0 1 2
1 2 2
1 4 2*/

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:57:6: warning: unused variable 'sout' [-Wunused-variable]
   57 |  int sout=s%1000;
      |      ^~~~
stations.cpp:59:6: warning: 'f' may be used uninitialized in this function [-Wmaybe-uninitialized]
   59 |  int f;
      |      ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 408 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=6009
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 284 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=1, label=1511
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 542 ms 644 KB Output is correct
2 Correct 511 ms 616 KB Output is correct
3 Correct 910 ms 400 KB Output is correct
4 Correct 705 ms 488 KB Output is correct
5 Correct 622 ms 400 KB Output is correct
6 Correct 441 ms 592 KB Output is correct
7 Correct 486 ms 476 KB Output is correct
8 Correct 3 ms 468 KB Output is correct
9 Correct 4 ms 492 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 588 ms 400 KB Output is correct
12 Correct 468 ms 692 KB Output is correct
13 Correct 502 ms 604 KB Output is correct
14 Correct 442 ms 476 KB Output is correct
15 Correct 56 ms 452 KB Output is correct
16 Correct 71 ms 548 KB Output is correct
17 Correct 142 ms 576 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 897 ms 400 KB Output is correct
2 Correct 692 ms 400 KB Output is correct
3 Correct 638 ms 464 KB Output is correct
4 Correct 3 ms 420 KB Output is correct
5 Correct 4 ms 468 KB Output is correct
6 Correct 2 ms 468 KB Output is correct
7 Correct 568 ms 488 KB Output is correct
8 Correct 868 ms 492 KB Output is correct
9 Correct 686 ms 488 KB Output is correct
10 Correct 610 ms 400 KB Output is correct
11 Correct 5 ms 468 KB Output is correct
12 Correct 7 ms 468 KB Output is correct
13 Correct 5 ms 468 KB Output is correct
14 Correct 4 ms 468 KB Output is correct
15 Correct 2 ms 492 KB Output is correct
16 Correct 550 ms 488 KB Output is correct
17 Correct 582 ms 400 KB Output is correct
18 Correct 550 ms 468 KB Output is correct
19 Correct 496 ms 400 KB Output is correct
20 Correct 417 ms 472 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 573 ms 648 KB Partially correct
2 Partially correct 445 ms 620 KB Partially correct
3 Partially correct 922 ms 484 KB Partially correct
4 Partially correct 724 ms 400 KB Partially correct
5 Partially correct 609 ms 484 KB Partially correct
6 Partially correct 521 ms 604 KB Partially correct
7 Partially correct 485 ms 480 KB Partially correct
8 Partially correct 2 ms 468 KB Partially correct
9 Partially correct 5 ms 468 KB Partially correct
10 Partially correct 2 ms 468 KB Partially correct
11 Partially correct 456 ms 536 KB Partially correct
12 Partially correct 512 ms 528 KB Partially correct
13 Partially correct 901 ms 400 KB Partially correct
14 Partially correct 688 ms 400 KB Partially correct
15 Partially correct 621 ms 488 KB Partially correct
16 Partially correct 491 ms 488 KB Partially correct
17 Partially correct 573 ms 400 KB Partially correct
18 Partially correct 424 ms 672 KB Partially correct
19 Partially correct 503 ms 736 KB Partially correct
20 Partially correct 437 ms 528 KB Partially correct
21 Partially correct 59 ms 444 KB Partially correct
22 Partially correct 76 ms 528 KB Partially correct
23 Partially correct 111 ms 528 KB Partially correct
24 Partially correct 5 ms 468 KB Partially correct
25 Partially correct 6 ms 468 KB Partially correct
26 Partially correct 4 ms 468 KB Partially correct
27 Partially correct 4 ms 420 KB Partially correct
28 Partially correct 4 ms 468 KB Partially correct
29 Partially correct 463 ms 400 KB Partially correct
30 Partially correct 550 ms 484 KB Partially correct
31 Partially correct 546 ms 484 KB Partially correct
32 Partially correct 517 ms 500 KB Partially correct
33 Partially correct 562 ms 484 KB Partially correct
34 Partially correct 303 ms 600 KB Partially correct
35 Partially correct 427 ms 684 KB Partially correct
36 Partially correct 490 ms 720 KB Partially correct
37 Partially correct 459 ms 688 KB Partially correct
38 Partially correct 474 ms 608 KB Partially correct
39 Partially correct 577 ms 616 KB Partially correct
40 Partially correct 445 ms 696 KB Partially correct
41 Partially correct 445 ms 616 KB Partially correct
42 Partially correct 74 ms 656 KB Partially correct
43 Partially correct 112 ms 528 KB Partially correct
44 Partially correct 126 ms 640 KB Partially correct
45 Partially correct 201 ms 580 KB Partially correct
46 Partially correct 384 ms 488 KB Partially correct
47 Partially correct 355 ms 488 KB Partially correct
48 Partially correct 68 ms 712 KB Partially correct
49 Partially correct 67 ms 824 KB Partially correct