Submission #416091

# Submission time Handle Problem Language Result Execution time Memory
416091 2021-06-02T00:13:26 Z duality Stations (IOI20_stations) C++14
100 / 100
1275 ms 4464 KB
#define DEBUG 0

#include <bits/stdc++.h>
using namespace std;

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------
#include "stations.h"

vi adjList[1000],L;
int num = 0;
int doDFS(int u,int p,int d) {
    int i;
    if (!d) L[u] = num++;
    for (i = 0; i < adjList[u].size(); i++) {
        int v = adjList[u][i];
        if (v != p) doDFS(v,u,!d);
    }
    if (d) L[u] = num++;
    return 0;
}
vector<int> label(int n,int k,vector<int> u,vector<int> v) {
    int i;
    for (i = 0; i < n-1; i++) adjList[u[i]].pb(v[i]),adjList[v[i]].pb(u[i]);
    L = vi(n),num = 0,doDFS(0,-1,0);
    for (i = 0; i < n; i++) adjList[i].clear();
    return L;
}
int find_next_station(int s,int t,vector<int> c) {
    if (s < c[0]) {
        if ((t < s) || (t >= c.back())) return c.back();
        else return *lower_bound(c.begin(),c.end(),t);
    }
    else {
        if ((t <= c[0]) || (t > s)) return c[0];
        else return *(--upper_bound(c.begin(),c.end(),t));
    }
}

Compilation message

stations.cpp: In function 'int doDFS(int, int, int)':
stations.cpp:64:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |     for (i = 0; i < adjList[u].size(); i++) {
      |                 ~~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 681 ms 644 KB Output is correct
2 Correct 540 ms 776 KB Output is correct
3 Correct 1077 ms 2192 KB Output is correct
4 Correct 981 ms 3884 KB Output is correct
5 Correct 698 ms 676 KB Output is correct
6 Correct 605 ms 640 KB Output is correct
7 Correct 541 ms 788 KB Output is correct
8 Correct 4 ms 3772 KB Output is correct
9 Correct 7 ms 456 KB Output is correct
10 Correct 3 ms 4192 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 772 ms 4284 KB Output is correct
2 Correct 878 ms 2196 KB Output is correct
3 Correct 1229 ms 1460 KB Output is correct
4 Correct 841 ms 4108 KB Output is correct
5 Correct 677 ms 472 KB Output is correct
6 Correct 706 ms 2236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 565 ms 756 KB Output is correct
2 Correct 641 ms 4028 KB Output is correct
3 Correct 1216 ms 4144 KB Output is correct
4 Correct 747 ms 1736 KB Output is correct
5 Correct 657 ms 3960 KB Output is correct
6 Correct 550 ms 2384 KB Output is correct
7 Correct 593 ms 600 KB Output is correct
8 Correct 5 ms 548 KB Output is correct
9 Correct 6 ms 428 KB Output is correct
10 Correct 3 ms 604 KB Output is correct
11 Correct 831 ms 644 KB Output is correct
12 Correct 505 ms 868 KB Output is correct
13 Correct 616 ms 1764 KB Output is correct
14 Correct 609 ms 680 KB Output is correct
15 Correct 52 ms 432 KB Output is correct
16 Correct 91 ms 1060 KB Output is correct
17 Correct 118 ms 808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1097 ms 1920 KB Output is correct
2 Correct 746 ms 1620 KB Output is correct
3 Correct 762 ms 760 KB Output is correct
4 Correct 5 ms 956 KB Output is correct
5 Correct 8 ms 492 KB Output is correct
6 Correct 5 ms 1340 KB Output is correct
7 Correct 1003 ms 3092 KB Output is correct
8 Correct 1275 ms 1704 KB Output is correct
9 Correct 846 ms 2200 KB Output is correct
10 Correct 769 ms 656 KB Output is correct
11 Correct 7 ms 444 KB Output is correct
12 Correct 7 ms 2400 KB Output is correct
13 Correct 11 ms 436 KB Output is correct
14 Correct 5 ms 1448 KB Output is correct
15 Correct 5 ms 548 KB Output is correct
16 Correct 643 ms 1396 KB Output is correct
17 Correct 863 ms 648 KB Output is correct
18 Correct 697 ms 840 KB Output is correct
19 Correct 587 ms 604 KB Output is correct
20 Correct 689 ms 632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 723 ms 1984 KB Output is correct
2 Correct 602 ms 3360 KB Output is correct
3 Correct 1051 ms 2208 KB Output is correct
4 Correct 927 ms 572 KB Output is correct
5 Correct 737 ms 508 KB Output is correct
6 Correct 585 ms 612 KB Output is correct
7 Correct 504 ms 740 KB Output is correct
8 Correct 5 ms 428 KB Output is correct
9 Correct 6 ms 560 KB Output is correct
10 Correct 4 ms 456 KB Output is correct
11 Correct 594 ms 616 KB Output is correct
12 Correct 590 ms 548 KB Output is correct
13 Correct 1215 ms 624 KB Output is correct
14 Correct 918 ms 1196 KB Output is correct
15 Correct 578 ms 516 KB Output is correct
16 Correct 739 ms 3844 KB Output is correct
17 Correct 649 ms 756 KB Output is correct
18 Correct 534 ms 2424 KB Output is correct
19 Correct 623 ms 1576 KB Output is correct
20 Correct 511 ms 3896 KB Output is correct
21 Correct 103 ms 4156 KB Output is correct
22 Correct 93 ms 556 KB Output is correct
23 Correct 151 ms 664 KB Output is correct
24 Correct 8 ms 508 KB Output is correct
25 Correct 11 ms 552 KB Output is correct
26 Correct 7 ms 468 KB Output is correct
27 Correct 7 ms 504 KB Output is correct
28 Correct 4 ms 3776 KB Output is correct
29 Correct 542 ms 2172 KB Output is correct
30 Correct 665 ms 2108 KB Output is correct
31 Correct 655 ms 732 KB Output is correct
32 Correct 583 ms 1152 KB Output is correct
33 Correct 584 ms 1408 KB Output is correct
34 Correct 340 ms 2376 KB Output is correct
35 Correct 762 ms 1868 KB Output is correct
36 Correct 946 ms 4464 KB Output is correct
37 Correct 670 ms 3996 KB Output is correct
38 Correct 625 ms 4008 KB Output is correct
39 Correct 545 ms 1556 KB Output is correct
40 Correct 462 ms 880 KB Output is correct
41 Correct 647 ms 736 KB Output is correct
42 Correct 66 ms 556 KB Output is correct
43 Correct 121 ms 700 KB Output is correct
44 Correct 188 ms 528 KB Output is correct
45 Correct 194 ms 732 KB Output is correct
46 Correct 417 ms 616 KB Output is correct
47 Correct 638 ms 1400 KB Output is correct
48 Correct 118 ms 4384 KB Output is correct
49 Correct 73 ms 3988 KB Output is correct