# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
433398 | 2021-06-19T16:55:21 Z | Enkognit | Stations (IOI20_stations) | C++14 | 901 ms | 864 KB |
#include <bits/stdc++.h> #include "stations.h" #include <vector> #define ll long long #define mp make_pair #define pb push_back #define fi first #define se second using namespace std; vector<int> c[1005]; vector<int> vv; ll T; void dfs(int h,int k, int p) { if (k%2==0) vv[h]=T++; for (int i = 0; i < c[h].size(); i++) if (c[h][i]!=p) { dfs(c[h][i], k+1, h); } if (k%2) vv[h]=T++; } std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) { vector<int> f; vv.resize(n, 0); T=0; vector<pair<ll, ll> > ed; for (int i = 0; i < u.size(); i++) { ed.pb(mp(u[i], v[i])); c[u[i]].pb(v[i]); c[v[i]].pb(u[i]); } dfs(0, 0, 0); f.resize(n, 0); f=vv; vv.clear(); //for (int i = 0; i < n; i++) cout << vv[i] << "\n"; //for (int i = 0; i < ed.size(); i++) // cout << vv[ed[i].fi] << " " << vv[ed[i].se] << "\n"; //cout << "---\n"; for (int i = 0; i < n; i++) c[i].clear(); return f; } int find_next_station(int s, int t, std::vector<int> c) { /*cout << c.size() << " : "; for (int i = 0; i < c.size(); i++) cout << c[i] << " "; cout << "\n"; cout << s << "\n";*/ if (s==t) return s; if (c.size()==1) return c[0]; //cout << "\n"; //assert((int)c.size()==0); if (s<c[0]) { if (t<s) return c.back(); for (int i = 0; i < c.size(); i++) if (t<=c[i]) return c[i]; return c.back(); }else { if (t>s) return c[0]; for (int i = c.size()-1; i > -1; i--) if (t>=c[i]) return c[i]; return c[0]; } assert(0); return 1; } /* 1 5 10 0 1 1 2 1 3 2 4 2 2 0 2 1 3 3 */
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 554 ms | 692 KB | Output is correct |
2 | Correct | 436 ms | 688 KB | Output is correct |
3 | Correct | 898 ms | 400 KB | Output is correct |
4 | Correct | 609 ms | 508 KB | Output is correct |
5 | Correct | 544 ms | 536 KB | Output is correct |
6 | Correct | 463 ms | 656 KB | Output is correct |
7 | Correct | 429 ms | 644 KB | Output is correct |
8 | Correct | 3 ms | 468 KB | Output is correct |
9 | Correct | 4 ms | 476 KB | Output is correct |
10 | Correct | 2 ms | 468 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 480 ms | 508 KB | Output is correct |
2 | Correct | 541 ms | 528 KB | Output is correct |
3 | Correct | 850 ms | 472 KB | Output is correct |
4 | Correct | 696 ms | 512 KB | Output is correct |
5 | Correct | 540 ms | 516 KB | Output is correct |
6 | Correct | 437 ms | 516 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 563 ms | 632 KB | Output is correct |
2 | Correct | 450 ms | 668 KB | Output is correct |
3 | Correct | 850 ms | 400 KB | Output is correct |
4 | Correct | 754 ms | 400 KB | Output is correct |
5 | Correct | 589 ms | 520 KB | Output is correct |
6 | Correct | 412 ms | 628 KB | Output is correct |
7 | Correct | 443 ms | 644 KB | Output is correct |
8 | Correct | 3 ms | 476 KB | Output is correct |
9 | Correct | 4 ms | 468 KB | Output is correct |
10 | Correct | 2 ms | 468 KB | Output is correct |
11 | Correct | 553 ms | 400 KB | Output is correct |
12 | Correct | 448 ms | 776 KB | Output is correct |
13 | Correct | 500 ms | 648 KB | Output is correct |
14 | Correct | 438 ms | 516 KB | Output is correct |
15 | Correct | 55 ms | 468 KB | Output is correct |
16 | Correct | 62 ms | 548 KB | Output is correct |
17 | Correct | 108 ms | 656 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 839 ms | 540 KB | Output is correct |
2 | Correct | 678 ms | 400 KB | Output is correct |
3 | Correct | 556 ms | 528 KB | Output is correct |
4 | Correct | 3 ms | 468 KB | Output is correct |
5 | Correct | 5 ms | 468 KB | Output is correct |
6 | Correct | 2 ms | 480 KB | Output is correct |
7 | Correct | 575 ms | 400 KB | Output is correct |
8 | Correct | 896 ms | 400 KB | Output is correct |
9 | Correct | 611 ms | 488 KB | Output is correct |
10 | Correct | 613 ms | 492 KB | Output is correct |
11 | Correct | 5 ms | 468 KB | Output is correct |
12 | Correct | 5 ms | 468 KB | Output is correct |
13 | Correct | 4 ms | 468 KB | Output is correct |
14 | Correct | 4 ms | 468 KB | Output is correct |
15 | Correct | 2 ms | 468 KB | Output is correct |
16 | Correct | 506 ms | 400 KB | Output is correct |
17 | Correct | 515 ms | 400 KB | Output is correct |
18 | Correct | 462 ms | 516 KB | Output is correct |
19 | Correct | 486 ms | 508 KB | Output is correct |
20 | Correct | 501 ms | 508 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 521 ms | 668 KB | Output is correct |
2 | Correct | 408 ms | 648 KB | Output is correct |
3 | Correct | 901 ms | 488 KB | Output is correct |
4 | Correct | 675 ms | 560 KB | Output is correct |
5 | Correct | 559 ms | 400 KB | Output is correct |
6 | Correct | 498 ms | 640 KB | Output is correct |
7 | Correct | 455 ms | 512 KB | Output is correct |
8 | Correct | 4 ms | 468 KB | Output is correct |
9 | Correct | 6 ms | 472 KB | Output is correct |
10 | Correct | 1 ms | 432 KB | Output is correct |
11 | Correct | 474 ms | 508 KB | Output is correct |
12 | Correct | 567 ms | 572 KB | Output is correct |
13 | Correct | 891 ms | 556 KB | Output is correct |
14 | Correct | 639 ms | 528 KB | Output is correct |
15 | Correct | 611 ms | 456 KB | Output is correct |
16 | Correct | 470 ms | 528 KB | Output is correct |
17 | Correct | 653 ms | 576 KB | Output is correct |
18 | Correct | 472 ms | 864 KB | Output is correct |
19 | Correct | 486 ms | 636 KB | Output is correct |
20 | Correct | 452 ms | 520 KB | Output is correct |
21 | Correct | 62 ms | 468 KB | Output is correct |
22 | Correct | 69 ms | 528 KB | Output is correct |
23 | Correct | 98 ms | 516 KB | Output is correct |
24 | Correct | 5 ms | 476 KB | Output is correct |
25 | Correct | 6 ms | 468 KB | Output is correct |
26 | Correct | 5 ms | 468 KB | Output is correct |
27 | Correct | 4 ms | 468 KB | Output is correct |
28 | Correct | 2 ms | 468 KB | Output is correct |
29 | Correct | 534 ms | 588 KB | Output is correct |
30 | Correct | 551 ms | 508 KB | Output is correct |
31 | Correct | 511 ms | 512 KB | Output is correct |
32 | Correct | 508 ms | 400 KB | Output is correct |
33 | Correct | 493 ms | 580 KB | Output is correct |
34 | Correct | 330 ms | 840 KB | Output is correct |
35 | Correct | 471 ms | 644 KB | Output is correct |
36 | Correct | 408 ms | 728 KB | Output is correct |
37 | Correct | 472 ms | 720 KB | Output is correct |
38 | Correct | 460 ms | 792 KB | Output is correct |
39 | Correct | 460 ms | 608 KB | Output is correct |
40 | Correct | 497 ms | 608 KB | Output is correct |
41 | Correct | 445 ms | 616 KB | Output is correct |
42 | Correct | 71 ms | 624 KB | Output is correct |
43 | Correct | 116 ms | 524 KB | Output is correct |
44 | Correct | 119 ms | 620 KB | Output is correct |
45 | Correct | 154 ms | 636 KB | Output is correct |
46 | Correct | 302 ms | 588 KB | Output is correct |
47 | Correct | 367 ms | 636 KB | Output is correct |
48 | Correct | 67 ms | 656 KB | Output is correct |
49 | Correct | 70 ms | 780 KB | Output is correct |