Submission #569378

# Submission time Handle Problem Language Result Execution time Memory
569378 2022-05-27T11:00:42 Z DJ035 Stations (IOI20_stations) C++17
100 / 100
916 ms 6916 KB
#include "stations.h"
#include <bits/stdc++.h>
#define MEM 111111
#define sanic ios_base::sync_with_stdio(0)
#define x first
#define y second
#define sz size()
#define pb push_back
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;
const ll INF = 1e13+7;
const ll MOD = 1e9+7;
vector<ll> g[MEM];
ll lb[MEM];
ll o;
void dfs(ll c, ll lv, ll p){
    if(lv&1) lb[c] = o++;
    for(ll nt:g[c]){
        if(nt==p) continue;
        dfs(nt, lv+1, c);
    }
    if(!(lv&1)) lb[c] = o++;
}
std::vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
	std::vector<int> labels(n);
	for(int i=0; i<n; i++) g[i].clear();
	for(int i=0; i<u.sz; i++){
        g[u[i]].pb(v[i]);
        g[v[i]].pb(u[i]);
	}
	memset(lb, 0, sizeof(lb));
	o = 0;
	dfs(0, 1, -1);
	for(int i=0; i<n; i++)
        labels[i] = lb[i];
	return labels;
}

int find_next_station(int s, int t, std::vector<int> c) {
    if(c.back()<s) reverse(c.begin(), c.end());
    for(int r : c)
        if(min(s, r)<=t && t<=max(s, r)) return r;
    return c.back();
}

Compilation message

stations.cpp: In function 'std::vector<int> label(int, int, std::vector<int>, std::vector<int>)':
stations.cpp:29:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |  for(int i=0; i<u.sz; i++){
      |                ^
# Verdict Execution time Memory Grader output
1 Correct 485 ms 6700 KB Output is correct
2 Correct 397 ms 6696 KB Output is correct
3 Correct 792 ms 6552 KB Output is correct
4 Correct 624 ms 6556 KB Output is correct
5 Correct 500 ms 6560 KB Output is correct
6 Correct 408 ms 6700 KB Output is correct
7 Correct 423 ms 6704 KB Output is correct
8 Correct 6 ms 6644 KB Output is correct
9 Correct 7 ms 6652 KB Output is correct
10 Correct 4 ms 6644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 382 ms 6696 KB Output is correct
2 Correct 459 ms 6700 KB Output is correct
3 Correct 818 ms 6568 KB Output is correct
4 Correct 634 ms 6564 KB Output is correct
5 Correct 542 ms 6572 KB Output is correct
6 Correct 427 ms 6680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 527 ms 6708 KB Output is correct
2 Correct 489 ms 6760 KB Output is correct
3 Correct 890 ms 6640 KB Output is correct
4 Correct 650 ms 6580 KB Output is correct
5 Correct 630 ms 6692 KB Output is correct
6 Correct 448 ms 6700 KB Output is correct
7 Correct 380 ms 6704 KB Output is correct
8 Correct 7 ms 6644 KB Output is correct
9 Correct 9 ms 6700 KB Output is correct
10 Correct 6 ms 6644 KB Output is correct
11 Correct 516 ms 6576 KB Output is correct
12 Correct 459 ms 6704 KB Output is correct
13 Correct 493 ms 6836 KB Output is correct
14 Correct 403 ms 6688 KB Output is correct
15 Correct 51 ms 6772 KB Output is correct
16 Correct 71 ms 6692 KB Output is correct
17 Correct 115 ms 6700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 916 ms 6560 KB Output is correct
2 Correct 743 ms 6572 KB Output is correct
3 Correct 603 ms 6608 KB Output is correct
4 Correct 6 ms 6644 KB Output is correct
5 Correct 6 ms 6644 KB Output is correct
6 Correct 6 ms 6640 KB Output is correct
7 Correct 590 ms 6624 KB Output is correct
8 Correct 888 ms 6572 KB Output is correct
9 Correct 579 ms 6596 KB Output is correct
10 Correct 626 ms 6620 KB Output is correct
11 Correct 9 ms 6716 KB Output is correct
12 Correct 8 ms 6644 KB Output is correct
13 Correct 7 ms 6640 KB Output is correct
14 Correct 11 ms 6644 KB Output is correct
15 Correct 7 ms 6624 KB Output is correct
16 Correct 519 ms 6560 KB Output is correct
17 Correct 489 ms 6576 KB Output is correct
18 Correct 459 ms 6576 KB Output is correct
19 Correct 505 ms 6708 KB Output is correct
20 Correct 514 ms 6584 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 541 ms 6736 KB Output is correct
2 Correct 398 ms 6700 KB Output is correct
3 Correct 866 ms 6572 KB Output is correct
4 Correct 647 ms 6632 KB Output is correct
5 Correct 546 ms 6572 KB Output is correct
6 Correct 452 ms 6768 KB Output is correct
7 Correct 478 ms 6688 KB Output is correct
8 Correct 6 ms 6688 KB Output is correct
9 Correct 10 ms 6644 KB Output is correct
10 Correct 5 ms 6644 KB Output is correct
11 Correct 460 ms 6700 KB Output is correct
12 Correct 583 ms 6812 KB Output is correct
13 Correct 888 ms 6712 KB Output is correct
14 Correct 660 ms 6636 KB Output is correct
15 Correct 557 ms 6592 KB Output is correct
16 Correct 430 ms 6708 KB Output is correct
17 Correct 532 ms 6628 KB Output is correct
18 Correct 454 ms 6824 KB Output is correct
19 Correct 503 ms 6780 KB Output is correct
20 Correct 415 ms 6708 KB Output is correct
21 Correct 61 ms 6840 KB Output is correct
22 Correct 65 ms 6692 KB Output is correct
23 Correct 113 ms 6740 KB Output is correct
24 Correct 7 ms 6648 KB Output is correct
25 Correct 8 ms 6644 KB Output is correct
26 Correct 9 ms 6708 KB Output is correct
27 Correct 8 ms 6760 KB Output is correct
28 Correct 5 ms 6692 KB Output is correct
29 Correct 475 ms 6640 KB Output is correct
30 Correct 512 ms 6556 KB Output is correct
31 Correct 496 ms 6552 KB Output is correct
32 Correct 547 ms 6548 KB Output is correct
33 Correct 490 ms 6564 KB Output is correct
34 Correct 327 ms 6716 KB Output is correct
35 Correct 430 ms 6884 KB Output is correct
36 Correct 423 ms 6688 KB Output is correct
37 Correct 451 ms 6776 KB Output is correct
38 Correct 512 ms 6828 KB Output is correct
39 Correct 527 ms 6708 KB Output is correct
40 Correct 520 ms 6748 KB Output is correct
41 Correct 580 ms 6788 KB Output is correct
42 Correct 75 ms 6708 KB Output is correct
43 Correct 101 ms 6704 KB Output is correct
44 Correct 166 ms 6828 KB Output is correct
45 Correct 202 ms 6880 KB Output is correct
46 Correct 358 ms 6728 KB Output is correct
47 Correct 338 ms 6704 KB Output is correct
48 Correct 71 ms 6916 KB Output is correct
49 Correct 62 ms 6796 KB Output is correct