답안 #400323

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
400323 2021-05-07T21:10:34 Z REALITYNB 기지국 (IOI20_stations) C++14
100 / 100
1156 ms 992 KB
#include <bits/stdc++.h> 
#include "stations.h"
using namespace std; 
vector<int> label(int n ,int l , 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]); 
    }
    function<vector<int>(int,int,int)> dfs = [&](int a ,int p , int lvl){
        vector<int> ans ; 
        if(lvl)
            ans.push_back(a) ; 
        for(int x : adj[a]){
            if(x!=p){
                vector<int> res = dfs(x,a,lvl^1) ; 
                for(int x :res) ans.push_back(x) ;
            }
        }
        if(lvl==0) ans.push_back(a) ; 
        return ans ; 
    }; 
    vector<int> res  = dfs(0,-1,1) ; 
    for(int i=0;i<n;i++) ans[res[i]]=i ; 
    return ans ; 
}
int find_next_station(int u , int v , vector<int> ne){
    if(u==0){
        if(u<=v&&v<=ne[0]) return ne[0] ; 
        for(int i=1;i<ne.size();i++) if(ne[i]>=v&&v>ne[i-1]) return ne[i] ; 
    }
    if(u<=ne[0]){
        int dad = ne.back() ; 
        if(u<=v&&v<=ne[0]) return ne[0] ; 
        for(int i=1;i+1<ne.size();i++)
            if(ne[i]>=v&&v>ne[i-1]) return ne[i] ; 
        return dad ; 
    }
    else{
        int dad = ne[0] ;
        if(u>=v&&v>=ne.back()) return ne.back() ;  
        for(int i=(int)(ne.size()-2);i>0;i--)
            if(ne[i+1]>v&&v>=ne[i]) return ne[i] ; 
        return dad ; 
    }
    return 5/0; 
}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:31:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |         for(int i=1;i<ne.size();i++) if(ne[i]>=v&&v>ne[i-1]) return ne[i] ;
      |                     ~^~~~~~~~~~
stations.cpp:36:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |         for(int i=1;i+1<ne.size();i++)
      |                     ~~~^~~~~~~~~~
stations.cpp:47:13: warning: division by zero [-Wdiv-by-zero]
   47 |     return 5/0;
      |            ~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 650 ms 656 KB Output is correct
2 Correct 526 ms 660 KB Output is correct
3 Correct 1077 ms 412 KB Output is correct
4 Correct 858 ms 492 KB Output is correct
5 Correct 786 ms 400 KB Output is correct
6 Correct 561 ms 624 KB Output is correct
7 Correct 563 ms 660 KB Output is correct
8 Correct 3 ms 480 KB Output is correct
9 Correct 5 ms 476 KB Output is correct
10 Correct 2 ms 480 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 485 ms 544 KB Output is correct
2 Correct 741 ms 488 KB Output is correct
3 Correct 1156 ms 400 KB Output is correct
4 Correct 829 ms 400 KB Output is correct
5 Correct 803 ms 492 KB Output is correct
6 Correct 473 ms 488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 574 ms 656 KB Output is correct
2 Correct 644 ms 656 KB Output is correct
3 Correct 858 ms 400 KB Output is correct
4 Correct 828 ms 560 KB Output is correct
5 Correct 750 ms 492 KB Output is correct
6 Correct 649 ms 620 KB Output is correct
7 Correct 633 ms 656 KB Output is correct
8 Correct 3 ms 480 KB Output is correct
9 Correct 5 ms 472 KB Output is correct
10 Correct 2 ms 476 KB Output is correct
11 Correct 639 ms 400 KB Output is correct
12 Correct 591 ms 732 KB Output is correct
13 Correct 509 ms 744 KB Output is correct
14 Correct 580 ms 528 KB Output is correct
15 Correct 70 ms 472 KB Output is correct
16 Correct 67 ms 492 KB Output is correct
17 Correct 145 ms 528 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1128 ms 492 KB Output is correct
2 Correct 842 ms 400 KB Output is correct
3 Correct 725 ms 612 KB Output is correct
4 Correct 3 ms 480 KB Output is correct
5 Correct 5 ms 468 KB Output is correct
6 Correct 2 ms 472 KB Output is correct
7 Correct 769 ms 496 KB Output is correct
8 Correct 1001 ms 400 KB Output is correct
9 Correct 962 ms 528 KB Output is correct
10 Correct 631 ms 496 KB Output is correct
11 Correct 7 ms 472 KB Output is correct
12 Correct 6 ms 472 KB Output is correct
13 Correct 6 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 589 ms 528 KB Output is correct
17 Correct 653 ms 528 KB Output is correct
18 Correct 634 ms 400 KB Output is correct
19 Correct 660 ms 528 KB Output is correct
20 Correct 610 ms 596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 641 ms 708 KB Output is correct
2 Correct 549 ms 612 KB Output is correct
3 Correct 1085 ms 400 KB Output is correct
4 Correct 653 ms 520 KB Output is correct
5 Correct 741 ms 520 KB Output is correct
6 Correct 598 ms 632 KB Output is correct
7 Correct 553 ms 656 KB Output is correct
8 Correct 3 ms 472 KB Output is correct
9 Correct 6 ms 472 KB Output is correct
10 Correct 2 ms 472 KB Output is correct
11 Correct 555 ms 484 KB Output is correct
12 Correct 536 ms 528 KB Output is correct
13 Correct 1059 ms 400 KB Output is correct
14 Correct 891 ms 500 KB Output is correct
15 Correct 610 ms 400 KB Output is correct
16 Correct 592 ms 484 KB Output is correct
17 Correct 527 ms 492 KB Output is correct
18 Correct 590 ms 656 KB Output is correct
19 Correct 610 ms 696 KB Output is correct
20 Correct 592 ms 528 KB Output is correct
21 Correct 64 ms 416 KB Output is correct
22 Correct 81 ms 612 KB Output is correct
23 Correct 120 ms 532 KB Output is correct
24 Correct 7 ms 500 KB Output is correct
25 Correct 6 ms 468 KB Output is correct
26 Correct 6 ms 472 KB Output is correct
27 Correct 3 ms 472 KB Output is correct
28 Correct 2 ms 472 KB Output is correct
29 Correct 727 ms 528 KB Output is correct
30 Correct 535 ms 404 KB Output is correct
31 Correct 622 ms 400 KB Output is correct
32 Correct 633 ms 400 KB Output is correct
33 Correct 641 ms 400 KB Output is correct
34 Correct 393 ms 656 KB Output is correct
35 Correct 427 ms 736 KB Output is correct
36 Correct 621 ms 624 KB Output is correct
37 Correct 594 ms 732 KB Output is correct
38 Correct 513 ms 528 KB Output is correct
39 Correct 462 ms 992 KB Output is correct
40 Correct 531 ms 728 KB Output is correct
41 Correct 563 ms 740 KB Output is correct
42 Correct 72 ms 548 KB Output is correct
43 Correct 153 ms 544 KB Output is correct
44 Correct 136 ms 528 KB Output is correct
45 Correct 218 ms 544 KB Output is correct
46 Correct 295 ms 528 KB Output is correct
47 Correct 323 ms 784 KB Output is correct
48 Correct 57 ms 572 KB Output is correct
49 Correct 62 ms 656 KB Output is correct