Submission #552736

# Submission time Handle Problem Language Result Execution time Memory
552736 2022-04-23T18:24:04 Z neki Stations (IOI20_stations) C++14
100 / 100
821 ms 772 KB
#include <bits/stdc++.h>

using namespace std;

#define vc vector
#define fore(v, a) for(auto v:a)
#define loop(i, a, b) for(int i=a;i<b;++i)
#define pool(i, a, b) for(int i=a-1;i>=b;--i)

vc<int> label(int n, int k, vc<int> U, vc<int> V){
    vc<vc<int>> edg(n);
    for(int e=0;e<n-1;++e){
        edg[U[e]].push_back(V[e]);
        edg[V[e]].push_back(U[e]);
    }
    
    vc<int> ret(n);
    int cnt=0;
    function<void (int, int, int)> dfs=[&](int u, int p, int hei){
        if(hei%2==0)ret[u]=cnt++;
        fore(v, edg[u]) if(v!=p) dfs(v, u, hei+1);
        if(hei%2==1)ret[u]=cnt++;
    };
    dfs(0, -1, 0);
    //loop(i, 0, n) cout << ret[i]<<" ";cout << endl;
    return ret;
}
int find_next_station(int s, int t, vc<int> c){
    sort(c.begin(), c.end());
    if(s==0){ loop(i, 0, c.size()) if(t<=c[i]) return c[i];}
    else{
        if(s<c[0]){
            if(t<s) return c.back();
            loop(i, 0, c.size()-1) if(t<=c[i]) return c[i];
            return c.back();
        }
        if(s>c.back()){
            if(t>s) return c[0];
            pool(i, c.size(), 1) if(c[i]<=t) return c[i];
            return c[0];
        }
    }
}

Compilation message

stations.cpp: In function 'int find_next_station(int, int, std::vector<int>)':
stations.cpp:7:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 | #define loop(i, a, b) for(int i=a;i<b;++i)
......
   30 |     if(s==0){ loop(i, 0, c.size()) if(t<=c[i]) return c[i];}
      |                    ~~~~~~~~~~~~~~   
stations.cpp:30:15: note: in expansion of macro 'loop'
   30 |     if(s==0){ loop(i, 0, c.size()) if(t<=c[i]) return c[i];}
      |               ^~~~
stations.cpp:7:36: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 | #define loop(i, a, b) for(int i=a;i<b;++i)
......
   34 |             loop(i, 0, c.size()-1) if(t<=c[i]) return c[i];
      |                  ~~~~~~~~~~~~~~~~   
stations.cpp:34:13: note: in expansion of macro 'loop'
   34 |             loop(i, 0, c.size()-1) if(t<=c[i]) return c[i];
      |             ^~~~
stations.cpp:43:1: warning: control reaches end of non-void function [-Wreturn-type]
   43 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 482 ms 672 KB Output is correct
2 Correct 407 ms 632 KB Output is correct
3 Correct 804 ms 504 KB Output is correct
4 Correct 599 ms 484 KB Output is correct
5 Correct 521 ms 420 KB Output is correct
6 Correct 383 ms 632 KB Output is correct
7 Correct 404 ms 544 KB Output is correct
8 Correct 2 ms 492 KB Output is correct
9 Correct 4 ms 496 KB Output is correct
10 Correct 2 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 352 ms 676 KB Output is correct
2 Correct 473 ms 544 KB Output is correct
3 Correct 771 ms 544 KB Output is correct
4 Correct 559 ms 416 KB Output is correct
5 Correct 517 ms 504 KB Output is correct
6 Correct 411 ms 548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 511 ms 696 KB Output is correct
2 Correct 398 ms 672 KB Output is correct
3 Correct 701 ms 416 KB Output is correct
4 Correct 593 ms 508 KB Output is correct
5 Correct 503 ms 484 KB Output is correct
6 Correct 433 ms 676 KB Output is correct
7 Correct 410 ms 644 KB Output is correct
8 Correct 3 ms 500 KB Output is correct
9 Correct 3 ms 500 KB Output is correct
10 Correct 1 ms 492 KB Output is correct
11 Correct 422 ms 416 KB Output is correct
12 Correct 451 ms 756 KB Output is correct
13 Correct 488 ms 772 KB Output is correct
14 Correct 355 ms 504 KB Output is correct
15 Correct 48 ms 420 KB Output is correct
16 Correct 60 ms 568 KB Output is correct
17 Correct 107 ms 668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 821 ms 504 KB Output is correct
2 Correct 587 ms 504 KB Output is correct
3 Correct 580 ms 504 KB Output is correct
4 Correct 1 ms 488 KB Output is correct
5 Correct 4 ms 500 KB Output is correct
6 Correct 1 ms 492 KB Output is correct
7 Correct 496 ms 420 KB Output is correct
8 Correct 743 ms 428 KB Output is correct
9 Correct 602 ms 500 KB Output is correct
10 Correct 478 ms 504 KB Output is correct
11 Correct 5 ms 492 KB Output is correct
12 Correct 6 ms 492 KB Output is correct
13 Correct 4 ms 492 KB Output is correct
14 Correct 3 ms 492 KB Output is correct
15 Correct 1 ms 492 KB Output is correct
16 Correct 485 ms 420 KB Output is correct
17 Correct 446 ms 508 KB Output is correct
18 Correct 451 ms 416 KB Output is correct
19 Correct 373 ms 508 KB Output is correct
20 Correct 400 ms 500 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 515 ms 632 KB Output is correct
2 Correct 420 ms 664 KB Output is correct
3 Correct 622 ms 416 KB Output is correct
4 Correct 551 ms 504 KB Output is correct
5 Correct 497 ms 512 KB Output is correct
6 Correct 342 ms 688 KB Output is correct
7 Correct 383 ms 636 KB Output is correct
8 Correct 3 ms 492 KB Output is correct
9 Correct 4 ms 492 KB Output is correct
10 Correct 0 ms 500 KB Output is correct
11 Correct 403 ms 544 KB Output is correct
12 Correct 504 ms 504 KB Output is correct
13 Correct 776 ms 416 KB Output is correct
14 Correct 552 ms 416 KB Output is correct
15 Correct 561 ms 420 KB Output is correct
16 Correct 374 ms 548 KB Output is correct
17 Correct 501 ms 420 KB Output is correct
18 Correct 400 ms 716 KB Output is correct
19 Correct 372 ms 632 KB Output is correct
20 Correct 400 ms 548 KB Output is correct
21 Correct 53 ms 488 KB Output is correct
22 Correct 63 ms 572 KB Output is correct
23 Correct 102 ms 544 KB Output is correct
24 Correct 3 ms 492 KB Output is correct
25 Correct 5 ms 488 KB Output is correct
26 Correct 3 ms 492 KB Output is correct
27 Correct 3 ms 500 KB Output is correct
28 Correct 2 ms 500 KB Output is correct
29 Correct 455 ms 416 KB Output is correct
30 Correct 433 ms 416 KB Output is correct
31 Correct 381 ms 548 KB Output is correct
32 Correct 479 ms 508 KB Output is correct
33 Correct 446 ms 420 KB Output is correct
34 Correct 323 ms 636 KB Output is correct
35 Correct 332 ms 708 KB Output is correct
36 Correct 408 ms 640 KB Output is correct
37 Correct 368 ms 676 KB Output is correct
38 Correct 412 ms 584 KB Output is correct
39 Correct 363 ms 692 KB Output is correct
40 Correct 386 ms 688 KB Output is correct
41 Correct 358 ms 632 KB Output is correct
42 Correct 57 ms 600 KB Output is correct
43 Correct 94 ms 632 KB Output is correct
44 Correct 123 ms 544 KB Output is correct
45 Correct 172 ms 544 KB Output is correct
46 Correct 286 ms 508 KB Output is correct
47 Correct 242 ms 632 KB Output is correct
48 Correct 56 ms 544 KB Output is correct
49 Correct 53 ms 756 KB Output is correct