답안 #392997

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
392997 2021-04-22T13:52:13 Z REALITYNB 기지국 (IOI20_stations) C++14
30.9499 / 100
1109 ms 784 KB
    #include <bits/stdc++.h> 
    #include "stations.h"
    #define pii pair<int,int> 
    #define in first 
    #define out second
    #define mp make_pair 
    using namespace std; 
     
    vector<int> label(int n ,int k , vector<int> u , vector<int> v){
    	vector<int> ans(n) ; 
    	vector<int> adj[n] ; 
    	for(int i=0;i<n-1;i++) {
    		adj[u[i]].push_back(v[i]) ; 
    		adj[v[i]].push_back(u[i]) ; 
    	}
    	int tim = 0 ; 
    	vector<int> inn(n) , outt(n) ; 
    	function<void(int,int)> dfs = [&](int a, int p){
    		inn[a]=tim++; 
    		for(int x :adj[a]){
    			if(x!=p){
    				dfs(x,a) ; 
    			}
    		}
    		outt[a]=tim++ ; 
    	}; 
    	dfs(0,0) ; 
    	for(int i=0;i<n;i++)
    		ans[i]=inn[i]+((outt[i])<<11);
    	return ans ; 
    }
    pii get(int x){
    	return mp(x%(1<<11),(x>>11)) ; 
    }
    bool ancestor(pii s, pii b){
    	return (s.in<=b.in&&b.out<=s.out); 
    }
    int find_next_station(int s ,int t, vector<int> ne){
    	pii ss = get(s) , tt = get(t) ; 
    	if(ancestor(ss,tt)^1){
    		for(int x : ne){
    			if(ancestor(get(x),ss)){
    				return x ; 
    			}
    		}
    	}
    	for(int x : ne){
    		if(ancestor(get(x),ss)^1 && ancestor(get(x),tt)){
    			return x ; 
    		}
    	}
    	if(s==t) return s ; 
    	return 1 ; 
    }
    /*int main(){
    	vector<int> u= {0,1,2} , v = {1,2,3} ;
    	vector<int> res = label(4,1000000,u,v) ; 
    	for(int x : res) cout << x <<" " ; 
    	cout << endl ; 
    	for(int i=0;i<4;i++){
    		for(int j=0;j<4;j++){
    			if(i!=j){
    				cout << i << " "<< j << ": " << find_next_station(i,j,adj[i]) << endl ; 
    			}
    		}
    	}
    	return 0 ; 
    }*/
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 420 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=0, label=38912
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 328 KB Invalid labels (values out of range). scenario=0, k=1000, vertex=0, label=4077568
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 468 KB Invalid labels (values out of range). scenario=1, k=1000000, vertex=0, label=4081664
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1109 ms 520 KB Output is correct
2 Correct 747 ms 400 KB Output is correct
3 Correct 717 ms 488 KB Output is correct
4 Correct 3 ms 472 KB Output is correct
5 Correct 3 ms 472 KB Output is correct
6 Correct 1 ms 472 KB Output is correct
7 Correct 702 ms 400 KB Output is correct
8 Correct 946 ms 420 KB Output is correct
9 Correct 874 ms 488 KB Output is correct
10 Correct 686 ms 564 KB Output is correct
11 Correct 7 ms 472 KB Output is correct
12 Correct 7 ms 472 KB Output is correct
13 Correct 5 ms 472 KB Output is correct
14 Correct 4 ms 472 KB Output is correct
15 Correct 2 ms 472 KB Output is correct
16 Correct 657 ms 400 KB Output is correct
17 Correct 648 ms 428 KB Output is correct
18 Correct 496 ms 404 KB Output is correct
19 Correct 509 ms 404 KB Output is correct
20 Correct 500 ms 400 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 561 ms 668 KB Partially correct
2 Partially correct 481 ms 612 KB Partially correct
3 Partially correct 1075 ms 492 KB Partially correct
4 Partially correct 840 ms 492 KB Partially correct
5 Partially correct 774 ms 492 KB Partially correct
6 Partially correct 488 ms 784 KB Partially correct
7 Partially correct 584 ms 500 KB Partially correct
8 Partially correct 3 ms 472 KB Partially correct
9 Partially correct 5 ms 472 KB Partially correct
10 Partially correct 1 ms 480 KB Partially correct
11 Partially correct 505 ms 528 KB Partially correct
12 Partially correct 578 ms 528 KB Partially correct
13 Partially correct 980 ms 404 KB Partially correct
14 Partially correct 855 ms 492 KB Partially correct
15 Partially correct 772 ms 472 KB Partially correct
16 Partially correct 500 ms 488 KB Partially correct
17 Partially correct 651 ms 400 KB Partially correct
18 Partially correct 573 ms 532 KB Partially correct
19 Partially correct 519 ms 712 KB Partially correct
20 Partially correct 548 ms 556 KB Partially correct
21 Partially correct 67 ms 420 KB Partially correct
22 Partially correct 89 ms 560 KB Partially correct
23 Partially correct 146 ms 532 KB Partially correct
24 Partially correct 7 ms 472 KB Partially correct
25 Partially correct 5 ms 472 KB Partially correct
26 Partially correct 6 ms 476 KB Partially correct
27 Partially correct 4 ms 472 KB Partially correct
28 Partially correct 2 ms 472 KB Partially correct
29 Partially correct 581 ms 400 KB Partially correct
30 Partially correct 553 ms 400 KB Partially correct
31 Partially correct 589 ms 616 KB Partially correct
32 Partially correct 603 ms 488 KB Partially correct
33 Partially correct 565 ms 492 KB Partially correct
34 Partially correct 392 ms 532 KB Partially correct
35 Partially correct 527 ms 660 KB Partially correct
36 Partially correct 608 ms 780 KB Partially correct
37 Partially correct 610 ms 484 KB Partially correct
38 Partially correct 560 ms 528 KB Partially correct
39 Partially correct 623 ms 576 KB Partially correct
40 Partially correct 526 ms 608 KB Partially correct
41 Partially correct 571 ms 608 KB Partially correct
42 Partially correct 82 ms 528 KB Partially correct
43 Partially correct 97 ms 528 KB Partially correct
44 Partially correct 134 ms 528 KB Partially correct
45 Partially correct 151 ms 528 KB Partially correct
46 Partially correct 430 ms 528 KB Partially correct
47 Partially correct 378 ms 660 KB Partially correct
48 Partially correct 69 ms 532 KB Partially correct
49 Partially correct 78 ms 668 KB Partially correct