답안 #964634

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
964634 2024-04-17T08:42:18 Z irmuun 기지국 (IOI20_stations) C++17
100 / 100
591 ms 1644 KB
#include<bits/stdc++.h>
#include "stations.h"

using namespace std;

#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()

const int N=1e3+5;
vector<int>adj[N],tin(N),tout(N),dep(N);
int cur=0;
void dfs(int x,int p){
    tin[x]=cur++;
    for(auto y:adj[x]){
        if(y!=p){
            dep[y]=dep[x]+1;
            dfs(y,x);
        }
    }
    tout[x]=cur++;
}

vector<int>label(int n,int k,vector<int>u,vector<int>v){
    cur=0;
    for(int i=0;i<n;i++){
        adj[i].clear();
    }
    for(int i=0;i<n-1;i++){
        adj[u[i]].pb(v[i]);
        adj[v[i]].pb(u[i]);
    }
    dfs(0,-1);
    vector<int>l(n);
    for(int i=0;i<n;i++){
        if(dep[i]%2==0){
            l[i]=tin[i];
        }
        else{
            l[i]=tout[i];
        }
        l[i]/=2;
    }
    return l;
}
 
int find_next_station(int s,int t,vector<int>c){
    s*=2;
    t*=2;
    for(int i=0;i<c.size();i++) c[i]*=2;
    if(s<c[0]){
        int l=s+1;
        for(int i=0;i<(int)c.size()-1;i++){
            if(l<=t&&t<=c[i]){
                return c[i]/2;
            }
            l=c[i]+1;
        }
        return c.back()/2;
    }
    else{
        int r=s-1;
        for(int i=(int)c.size()-1;i>0;i--){
            if(c[i]<=t&&t<=r){
                return c[i]/2;
            }
            r=c[i]-1;
        }
        return c[0]/2;
    }
    return 0;
}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:53:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |     for(int i=0;i<c.size();i++) c[i]*=2;
      |                 ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 351 ms 924 KB Output is correct
2 Correct 287 ms 924 KB Output is correct
3 Correct 536 ms 688 KB Output is correct
4 Correct 419 ms 684 KB Output is correct
5 Correct 371 ms 684 KB Output is correct
6 Correct 289 ms 916 KB Output is correct
7 Correct 288 ms 684 KB Output is correct
8 Correct 1 ms 768 KB Output is correct
9 Correct 2 ms 1072 KB Output is correct
10 Correct 0 ms 836 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 304 ms 876 KB Output is correct
2 Correct 340 ms 816 KB Output is correct
3 Correct 544 ms 684 KB Output is correct
4 Correct 416 ms 684 KB Output is correct
5 Correct 377 ms 684 KB Output is correct
6 Correct 273 ms 844 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 342 ms 1180 KB Output is correct
2 Correct 277 ms 932 KB Output is correct
3 Correct 584 ms 684 KB Output is correct
4 Correct 417 ms 688 KB Output is correct
5 Correct 384 ms 684 KB Output is correct
6 Correct 293 ms 912 KB Output is correct
7 Correct 284 ms 684 KB Output is correct
8 Correct 2 ms 768 KB Output is correct
9 Correct 3 ms 768 KB Output is correct
10 Correct 1 ms 768 KB Output is correct
11 Correct 375 ms 684 KB Output is correct
12 Correct 290 ms 992 KB Output is correct
13 Correct 297 ms 1036 KB Output is correct
14 Correct 288 ms 684 KB Output is correct
15 Correct 37 ms 904 KB Output is correct
16 Correct 37 ms 940 KB Output is correct
17 Correct 57 ms 864 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 550 ms 684 KB Output is correct
2 Correct 430 ms 684 KB Output is correct
3 Correct 395 ms 684 KB Output is correct
4 Correct 2 ms 768 KB Output is correct
5 Correct 3 ms 768 KB Output is correct
6 Correct 1 ms 768 KB Output is correct
7 Correct 377 ms 684 KB Output is correct
8 Correct 559 ms 1192 KB Output is correct
9 Correct 417 ms 684 KB Output is correct
10 Correct 394 ms 684 KB Output is correct
11 Correct 3 ms 764 KB Output is correct
12 Correct 4 ms 764 KB Output is correct
13 Correct 3 ms 768 KB Output is correct
14 Correct 3 ms 768 KB Output is correct
15 Correct 1 ms 764 KB Output is correct
16 Correct 318 ms 684 KB Output is correct
17 Correct 331 ms 684 KB Output is correct
18 Correct 335 ms 684 KB Output is correct
19 Correct 330 ms 684 KB Output is correct
20 Correct 326 ms 684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 343 ms 924 KB Output is correct
2 Correct 287 ms 924 KB Output is correct
3 Correct 591 ms 684 KB Output is correct
4 Correct 399 ms 684 KB Output is correct
5 Correct 370 ms 684 KB Output is correct
6 Correct 276 ms 924 KB Output is correct
7 Correct 293 ms 864 KB Output is correct
8 Correct 2 ms 764 KB Output is correct
9 Correct 3 ms 768 KB Output is correct
10 Correct 1 ms 768 KB Output is correct
11 Correct 299 ms 876 KB Output is correct
12 Correct 341 ms 852 KB Output is correct
13 Correct 577 ms 684 KB Output is correct
14 Correct 424 ms 684 KB Output is correct
15 Correct 366 ms 684 KB Output is correct
16 Correct 296 ms 688 KB Output is correct
17 Correct 376 ms 684 KB Output is correct
18 Correct 284 ms 1056 KB Output is correct
19 Correct 285 ms 1540 KB Output is correct
20 Correct 281 ms 684 KB Output is correct
21 Correct 36 ms 900 KB Output is correct
22 Correct 40 ms 908 KB Output is correct
23 Correct 61 ms 1088 KB Output is correct
24 Correct 3 ms 764 KB Output is correct
25 Correct 4 ms 768 KB Output is correct
26 Correct 2 ms 768 KB Output is correct
27 Correct 3 ms 768 KB Output is correct
28 Correct 2 ms 768 KB Output is correct
29 Correct 333 ms 684 KB Output is correct
30 Correct 312 ms 684 KB Output is correct
31 Correct 336 ms 684 KB Output is correct
32 Correct 340 ms 684 KB Output is correct
33 Correct 327 ms 684 KB Output is correct
34 Correct 187 ms 904 KB Output is correct
35 Correct 275 ms 1072 KB Output is correct
36 Correct 279 ms 1044 KB Output is correct
37 Correct 304 ms 1148 KB Output is correct
38 Correct 299 ms 1412 KB Output is correct
39 Correct 289 ms 1044 KB Output is correct
40 Correct 262 ms 1024 KB Output is correct
41 Correct 285 ms 1144 KB Output is correct
42 Correct 36 ms 1132 KB Output is correct
43 Correct 72 ms 872 KB Output is correct
44 Correct 87 ms 924 KB Output is correct
45 Correct 102 ms 932 KB Output is correct
46 Correct 210 ms 940 KB Output is correct
47 Correct 205 ms 888 KB Output is correct
48 Correct 37 ms 952 KB Output is correct
49 Correct 36 ms 1644 KB Output is correct