Submission #608816

# Submission time Handle Problem Language Result Execution time Memory
608816 2022-07-27T10:25:50 Z Mounir Toy Train (IOI17_train) C++14
100 / 100
1470 ms 48232 KB
#include "train.h"
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define chmax(x, v) x = max(x, v)
#define chmin(x, v) x = min(x, v)
#define pb push_back
#define pii pair<int, int>
#define sz(x) (int)x.size()
#define x first
#define y second;
using namespace std;

const int N = 1e6;
bool aAlice[N];
vector<int> versMoi[N], voisins[N];
int fuckes[N];
int nNoeuds;
bool aAcces[N], propage[N];
bool estRecharge[N];

void updRecharges(){
    queue<int> file;
    for (int noeud = 0; noeud < nNoeuds; ++noeud){
        aAcces[noeud] = false;
        propage[noeud] = false;
        if (estRecharge[noeud])
            file.push(noeud);
        fuckes[noeud] = sz(voisins[noeud]);
    }
    
    while (!file.empty()){
        int noeud = file.front();
        file.pop();

        if (propage[noeud]) continue;
        propage[noeud] = true;

        for (int avant : versMoi[noeud]){
            fuckes[avant] --;
            if ((aAlice[avant] || fuckes[avant] == 0) && !aAcces[avant]){
                file.push(avant);
                aAcces[avant] = true;
            }
        }
    }

    for (int noeud = 0; noeud < nNoeuds; ++noeud)
        estRecharge[noeud] &= aAcces[noeud];
}

vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {  
    nNoeuds = sz(a);
    for (int noeud = 0; noeud < nNoeuds; ++noeud){
        aAlice[noeud] = a[noeud];
        estRecharge[noeud] = r[noeud];
    }
    int nAretes = sz(u);
    for (int i = 0; i < nAretes; ++i){
        voisins[u[i]].pb(v[i]);
        versMoi[v[i]].pb(u[i]);
    }

    for (int i = 0; i < nNoeuds; ++i)
        updRecharges();
    vector<int> res(nNoeuds);
    for (int i = 0; i < nNoeuds; ++i){
        res[i] = aAcces[i];
    }
	return res;
}
# Verdict Execution time Memory Grader output
1 Correct 516 ms 47824 KB Output is correct
2 Correct 489 ms 47820 KB Output is correct
3 Correct 482 ms 47828 KB Output is correct
4 Correct 476 ms 47828 KB Output is correct
5 Correct 464 ms 47828 KB Output is correct
6 Correct 501 ms 47812 KB Output is correct
7 Correct 227 ms 47828 KB Output is correct
8 Correct 818 ms 47828 KB Output is correct
9 Correct 503 ms 47800 KB Output is correct
10 Correct 495 ms 47780 KB Output is correct
11 Correct 432 ms 47700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 47316 KB Output is correct
2 Correct 25 ms 47280 KB Output is correct
3 Correct 25 ms 47188 KB Output is correct
4 Correct 26 ms 47176 KB Output is correct
5 Correct 24 ms 47308 KB Output is correct
6 Correct 23 ms 47316 KB Output is correct
7 Correct 23 ms 47272 KB Output is correct
8 Correct 23 ms 47188 KB Output is correct
9 Correct 23 ms 47188 KB Output is correct
10 Correct 24 ms 47228 KB Output is correct
11 Correct 23 ms 47188 KB Output is correct
12 Correct 23 ms 47192 KB Output is correct
13 Correct 24 ms 47272 KB Output is correct
14 Correct 23 ms 47260 KB Output is correct
15 Correct 23 ms 47188 KB Output is correct
16 Correct 27 ms 47260 KB Output is correct
17 Correct 24 ms 47256 KB Output is correct
18 Correct 23 ms 47280 KB Output is correct
19 Correct 23 ms 47292 KB Output is correct
20 Correct 22 ms 47188 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 200 ms 48180 KB Output is correct
2 Correct 262 ms 48200 KB Output is correct
3 Correct 286 ms 48164 KB Output is correct
4 Correct 1170 ms 48136 KB Output is correct
5 Correct 829 ms 48128 KB Output is correct
6 Correct 166 ms 48124 KB Output is correct
7 Correct 1470 ms 48132 KB Output is correct
8 Correct 483 ms 48176 KB Output is correct
9 Correct 150 ms 48100 KB Output is correct
10 Correct 843 ms 48108 KB Output is correct
11 Correct 590 ms 48084 KB Output is correct
12 Correct 146 ms 48048 KB Output is correct
13 Correct 1312 ms 48140 KB Output is correct
14 Correct 1295 ms 48140 KB Output is correct
15 Correct 1297 ms 48132 KB Output is correct
16 Correct 1299 ms 48140 KB Output is correct
17 Correct 1298 ms 48128 KB Output is correct
18 Correct 332 ms 47948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1004 ms 48008 KB Output is correct
2 Correct 854 ms 48084 KB Output is correct
3 Correct 180 ms 48104 KB Output is correct
4 Correct 143 ms 48124 KB Output is correct
5 Correct 604 ms 48116 KB Output is correct
6 Correct 872 ms 48204 KB Output is correct
7 Correct 821 ms 48092 KB Output is correct
8 Correct 169 ms 48084 KB Output is correct
9 Correct 880 ms 48068 KB Output is correct
10 Correct 1193 ms 48136 KB Output is correct
11 Correct 1138 ms 48140 KB Output is correct
12 Correct 1192 ms 48164 KB Output is correct
13 Correct 675 ms 48232 KB Output is correct
14 Correct 885 ms 48056 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 822 ms 48120 KB Output is correct
2 Correct 1434 ms 48136 KB Output is correct
3 Correct 1289 ms 48128 KB Output is correct
4 Correct 1419 ms 48048 KB Output is correct
5 Correct 24 ms 47364 KB Output is correct
6 Correct 145 ms 47760 KB Output is correct
7 Correct 59 ms 47804 KB Output is correct
8 Correct 30 ms 47828 KB Output is correct
9 Correct 58 ms 47828 KB Output is correct
10 Correct 26 ms 47468 KB Output is correct
11 Correct 91 ms 47804 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 516 ms 47824 KB Output is correct
2 Correct 489 ms 47820 KB Output is correct
3 Correct 482 ms 47828 KB Output is correct
4 Correct 476 ms 47828 KB Output is correct
5 Correct 464 ms 47828 KB Output is correct
6 Correct 501 ms 47812 KB Output is correct
7 Correct 227 ms 47828 KB Output is correct
8 Correct 818 ms 47828 KB Output is correct
9 Correct 503 ms 47800 KB Output is correct
10 Correct 495 ms 47780 KB Output is correct
11 Correct 432 ms 47700 KB Output is correct
12 Correct 24 ms 47316 KB Output is correct
13 Correct 25 ms 47280 KB Output is correct
14 Correct 25 ms 47188 KB Output is correct
15 Correct 26 ms 47176 KB Output is correct
16 Correct 24 ms 47308 KB Output is correct
17 Correct 23 ms 47316 KB Output is correct
18 Correct 23 ms 47272 KB Output is correct
19 Correct 23 ms 47188 KB Output is correct
20 Correct 23 ms 47188 KB Output is correct
21 Correct 24 ms 47228 KB Output is correct
22 Correct 23 ms 47188 KB Output is correct
23 Correct 23 ms 47192 KB Output is correct
24 Correct 24 ms 47272 KB Output is correct
25 Correct 23 ms 47260 KB Output is correct
26 Correct 23 ms 47188 KB Output is correct
27 Correct 27 ms 47260 KB Output is correct
28 Correct 24 ms 47256 KB Output is correct
29 Correct 23 ms 47280 KB Output is correct
30 Correct 23 ms 47292 KB Output is correct
31 Correct 22 ms 47188 KB Output is correct
32 Correct 200 ms 48180 KB Output is correct
33 Correct 262 ms 48200 KB Output is correct
34 Correct 286 ms 48164 KB Output is correct
35 Correct 1170 ms 48136 KB Output is correct
36 Correct 829 ms 48128 KB Output is correct
37 Correct 166 ms 48124 KB Output is correct
38 Correct 1470 ms 48132 KB Output is correct
39 Correct 483 ms 48176 KB Output is correct
40 Correct 150 ms 48100 KB Output is correct
41 Correct 843 ms 48108 KB Output is correct
42 Correct 590 ms 48084 KB Output is correct
43 Correct 146 ms 48048 KB Output is correct
44 Correct 1312 ms 48140 KB Output is correct
45 Correct 1295 ms 48140 KB Output is correct
46 Correct 1297 ms 48132 KB Output is correct
47 Correct 1299 ms 48140 KB Output is correct
48 Correct 1298 ms 48128 KB Output is correct
49 Correct 332 ms 47948 KB Output is correct
50 Correct 1004 ms 48008 KB Output is correct
51 Correct 854 ms 48084 KB Output is correct
52 Correct 180 ms 48104 KB Output is correct
53 Correct 143 ms 48124 KB Output is correct
54 Correct 604 ms 48116 KB Output is correct
55 Correct 872 ms 48204 KB Output is correct
56 Correct 821 ms 48092 KB Output is correct
57 Correct 169 ms 48084 KB Output is correct
58 Correct 880 ms 48068 KB Output is correct
59 Correct 1193 ms 48136 KB Output is correct
60 Correct 1138 ms 48140 KB Output is correct
61 Correct 1192 ms 48164 KB Output is correct
62 Correct 675 ms 48232 KB Output is correct
63 Correct 885 ms 48056 KB Output is correct
64 Correct 822 ms 48120 KB Output is correct
65 Correct 1434 ms 48136 KB Output is correct
66 Correct 1289 ms 48128 KB Output is correct
67 Correct 1419 ms 48048 KB Output is correct
68 Correct 24 ms 47364 KB Output is correct
69 Correct 145 ms 47760 KB Output is correct
70 Correct 59 ms 47804 KB Output is correct
71 Correct 30 ms 47828 KB Output is correct
72 Correct 58 ms 47828 KB Output is correct
73 Correct 26 ms 47468 KB Output is correct
74 Correct 91 ms 47804 KB Output is correct
75 Correct 228 ms 48176 KB Output is correct
76 Correct 252 ms 48172 KB Output is correct
77 Correct 296 ms 48164 KB Output is correct
78 Correct 284 ms 48076 KB Output is correct
79 Correct 287 ms 48108 KB Output is correct
80 Correct 1434 ms 48084 KB Output is correct
81 Correct 449 ms 48120 KB Output is correct
82 Correct 754 ms 48120 KB Output is correct
83 Correct 861 ms 48204 KB Output is correct
84 Correct 614 ms 48136 KB Output is correct
85 Correct 166 ms 48116 KB Output is correct
86 Correct 515 ms 48124 KB Output is correct
87 Correct 148 ms 48108 KB Output is correct
88 Correct 294 ms 48124 KB Output is correct
89 Correct 589 ms 48120 KB Output is correct
90 Correct 152 ms 48132 KB Output is correct
91 Correct 222 ms 48140 KB Output is correct
92 Correct 519 ms 48136 KB Output is correct
93 Correct 410 ms 48120 KB Output is correct
94 Correct 284 ms 48084 KB Output is correct
95 Correct 509 ms 48124 KB Output is correct
96 Correct 917 ms 48060 KB Output is correct
97 Correct 379 ms 48144 KB Output is correct
98 Correct 480 ms 48120 KB Output is correct
99 Correct 449 ms 48104 KB Output is correct
100 Correct 324 ms 47880 KB Output is correct