Submission #422347

# Submission time Handle Problem Language Result Execution time Memory
422347 2021-06-10T04:12:36 Z timmyfeng Toy Train (IOI17_train) C++17
23 / 100
300 ms 1696 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 5000;

vector<int> to[N], from[N], a;
bool win[N], visited[N];
int degree[N], n, m;

void bfs() {
    queue<int> que;
    for (int i = 0; i < n; ++i) {
        degree[i] = 0;
        if (visited[i]) {
            que.push(i);
        }
    }

    while (!que.empty()) {
        int u = que.front();
        que.pop();
        for (auto c : from[u]) {
            if (!visited[c]) {
                if (a[c] == 1 || ++degree[c] == (int) to[c].size()) {
                    visited[c] = true;
                    que.push(c);
                }
            }
        }
    }
}

vector<int> who_wins(vector<int> a, vector<int> r, vector<int> u, vector<int> v) {
    n = a.size(), m = u.size(), ::a = a;

    for (int i = 0; i < m; ++i) {
        to[u[i]].push_back(v[i]);
        from[v[i]].push_back(u[i]);
    }

    for (int i = 0; i < n; ++i) {
        if (r[i] == 1) {
            fill(visited, visited + n, false);
            visited[i] = true;
            bfs();
            if (a[i] == 1) {
                for (auto c : to[i]) {
                    win[i] |= visited[c];
                }
            } else {
                win[i] = true;
                for (auto c : to[i]) {
                    win[i] &= visited[c];
                }
            }
        }
    }

    copy(win, win + n, visited);
    bfs();

    return vector<int>(visited, visited + n);
}
# Verdict Execution time Memory Grader output
1 Incorrect 47 ms 1100 KB 3rd lines differ - on the 26th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 460 KB 3rd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 56 ms 1696 KB Output is correct
2 Correct 90 ms 1644 KB Output is correct
3 Correct 105 ms 1616 KB Output is correct
4 Correct 251 ms 1592 KB Output is correct
5 Correct 72 ms 1604 KB Output is correct
6 Correct 23 ms 1572 KB Output is correct
7 Correct 300 ms 1612 KB Output is correct
8 Correct 9 ms 1612 KB Output is correct
9 Correct 8 ms 1484 KB Output is correct
10 Correct 10 ms 1576 KB Output is correct
11 Correct 8 ms 1444 KB Output is correct
12 Correct 8 ms 1484 KB Output is correct
13 Correct 9 ms 1624 KB Output is correct
14 Correct 9 ms 1612 KB Output is correct
15 Correct 10 ms 1612 KB Output is correct
16 Correct 12 ms 1612 KB Output is correct
17 Correct 9 ms 1612 KB Output is correct
18 Correct 205 ms 1228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 85 ms 1360 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 1612 KB Output is correct
2 Correct 12 ms 1604 KB Output is correct
3 Correct 10 ms 1576 KB Output is correct
4 Correct 9 ms 1404 KB Output is correct
5 Correct 2 ms 540 KB Output is correct
6 Correct 5 ms 1084 KB Output is correct
7 Correct 6 ms 1196 KB Output is correct
8 Correct 6 ms 1228 KB Output is correct
9 Correct 6 ms 1208 KB Output is correct
10 Correct 2 ms 716 KB Output is correct
11 Correct 6 ms 1180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 47 ms 1100 KB 3rd lines differ - on the 26th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -