답안 #926165

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
926165 2024-02-12T16:04:32 Z winter0101 기지국 (IOI20_stations) C++14
100 / 100
592 ms 1420 KB
#include<bits/stdc++.h>
using namespace std;
#define all(fl) fl.begin(),fl.end()
#define pb push_back
#define fi first
#define se second
#define for1(i,j,k) for(int i=j;i<=k;i++)
#define for2(i,j,k) for(int i=j;i>=k;i--)
#define for3(i,j,k,l) for(int i=j;i<=k;i+=l)
#define lb lower_bound
#define ub upper_bound
#define sz(a) (int)a.size()
#define pii pair<int,int>
#define pli pair<long long,int>
#define gcd __gcd
#define lcm(x,y) x*y/__gcd(x,y)
const int maxn=1e3+9;
vector<int>a[maxn],in,dep;
int tme=0;
void dfs(int u,int par){
if (dep[u]%2==0)in[u]=++tme;
for (auto v:a[u]){
if (v==par)continue;
dep[v]=dep[u]+1;
dfs(v,u);
}
if (dep[u]%2==1)in[u]=++tme;
in[u]--;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
for1(i,0,n-1)a[i].clear();
for1(i,0,n-2)a[u[i]].pb(v[i]),a[v[i]].pb(u[i]);
in.resize(n),dep.resize(n);
tme=0;
dfs(0,0);
return in;
}
int find_next_station(int s, int t, std::vector<int> c) {
if (sz(c)==1)return c[0];
if (s>c[0]){//dep 1
if (t>=c[1]&&t<=s){
    for1(i,0,sz(c)-2){
    if (t>=c[i]&&t<=c[i+1]-1)return c[i];
    }
    return c.back();
}
else return c[0];
}
else {//dep 0
if (s==0){
    for2(i,sz(c)-1,1){
    if (c[i-1]+1<=t&&t<=c[i])return c[i];
    }
    return c[0];
}
if (t>=s&&t<=c[sz(c)-2]){
    for2(i,sz(c)-2,1){
    if (c[i-1]+1<=t&&t<=c[i])return c[i];
    }
    return c[0];
}
else {
return c.back();
}
}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 336 ms 908 KB Output is correct
2 Correct 292 ms 924 KB Output is correct
3 Correct 543 ms 952 KB Output is correct
4 Correct 407 ms 684 KB Output is correct
5 Correct 408 ms 684 KB Output is correct
6 Correct 267 ms 1208 KB Output is correct
7 Correct 300 ms 936 KB Output is correct
8 Correct 2 ms 768 KB Output is correct
9 Correct 2 ms 764 KB Output is correct
10 Correct 0 ms 1016 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 264 ms 880 KB Output is correct
2 Correct 373 ms 808 KB Output is correct
3 Correct 592 ms 792 KB Output is correct
4 Correct 435 ms 792 KB Output is correct
5 Correct 407 ms 684 KB Output is correct
6 Correct 293 ms 684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 349 ms 928 KB Output is correct
2 Correct 260 ms 908 KB Output is correct
3 Correct 553 ms 684 KB Output is correct
4 Correct 439 ms 684 KB Output is correct
5 Correct 390 ms 684 KB Output is correct
6 Correct 278 ms 912 KB Output is correct
7 Correct 281 ms 684 KB Output is correct
8 Correct 1 ms 768 KB Output is correct
9 Correct 2 ms 760 KB Output is correct
10 Correct 0 ms 768 KB Output is correct
11 Correct 401 ms 688 KB Output is correct
12 Correct 299 ms 1116 KB Output is correct
13 Correct 287 ms 1344 KB Output is correct
14 Correct 285 ms 684 KB Output is correct
15 Correct 33 ms 768 KB Output is correct
16 Correct 37 ms 924 KB Output is correct
17 Correct 60 ms 1192 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 573 ms 684 KB Output is correct
2 Correct 405 ms 684 KB Output is correct
3 Correct 389 ms 684 KB Output is correct
4 Correct 1 ms 764 KB Output is correct
5 Correct 2 ms 768 KB Output is correct
6 Correct 0 ms 768 KB Output is correct
7 Correct 387 ms 684 KB Output is correct
8 Correct 557 ms 684 KB Output is correct
9 Correct 414 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 1020 KB Output is correct
13 Correct 3 ms 764 KB Output is correct
14 Correct 3 ms 768 KB Output is correct
15 Correct 2 ms 768 KB Output is correct
16 Correct 302 ms 684 KB Output is correct
17 Correct 337 ms 684 KB Output is correct
18 Correct 346 ms 684 KB Output is correct
19 Correct 306 ms 684 KB Output is correct
20 Correct 275 ms 684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 381 ms 924 KB Output is correct
2 Correct 357 ms 916 KB Output is correct
3 Correct 568 ms 684 KB Output is correct
4 Correct 436 ms 684 KB Output is correct
5 Correct 337 ms 684 KB Output is correct
6 Correct 263 ms 900 KB Output is correct
7 Correct 290 ms 684 KB Output is correct
8 Correct 1 ms 768 KB Output is correct
9 Correct 3 ms 768 KB Output is correct
10 Correct 0 ms 768 KB Output is correct
11 Correct 297 ms 876 KB Output is correct
12 Correct 368 ms 836 KB Output is correct
13 Correct 573 ms 684 KB Output is correct
14 Correct 424 ms 684 KB Output is correct
15 Correct 403 ms 684 KB Output is correct
16 Correct 284 ms 684 KB Output is correct
17 Correct 374 ms 684 KB Output is correct
18 Correct 307 ms 1004 KB Output is correct
19 Correct 317 ms 1260 KB Output is correct
20 Correct 302 ms 684 KB Output is correct
21 Correct 28 ms 768 KB Output is correct
22 Correct 38 ms 840 KB Output is correct
23 Correct 59 ms 872 KB Output is correct
24 Correct 2 ms 780 KB Output is correct
25 Correct 3 ms 764 KB Output is correct
26 Correct 3 ms 768 KB Output is correct
27 Correct 2 ms 764 KB Output is correct
28 Correct 1 ms 768 KB Output is correct
29 Correct 323 ms 684 KB Output is correct
30 Correct 335 ms 684 KB Output is correct
31 Correct 345 ms 684 KB Output is correct
32 Correct 377 ms 684 KB Output is correct
33 Correct 350 ms 684 KB Output is correct
34 Correct 194 ms 900 KB Output is correct
35 Correct 300 ms 1420 KB Output is correct
36 Correct 292 ms 1020 KB Output is correct
37 Correct 309 ms 1024 KB Output is correct
38 Correct 276 ms 1160 KB Output is correct
39 Correct 230 ms 1016 KB Output is correct
40 Correct 282 ms 1008 KB Output is correct
41 Correct 289 ms 1244 KB Output is correct
42 Correct 42 ms 852 KB Output is correct
43 Correct 62 ms 944 KB Output is correct
44 Correct 76 ms 968 KB Output is correct
45 Correct 104 ms 948 KB Output is correct
46 Correct 187 ms 852 KB Output is correct
47 Correct 204 ms 908 KB Output is correct
48 Correct 37 ms 1264 KB Output is correct
49 Correct 32 ms 1352 KB Output is correct