Submission #733364

# Submission time Handle Problem Language Result Execution time Memory
733364 2023-04-30T14:45:29 Z t6twotwo Toy Train (IOI17_train) C++17
0 / 100
2000 ms 1156 KB
#include "train.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> who_wins(vector<int> A, vector<int> R, vector<int> U, vector<int> V) {
    int N = A.size();
    int M = U.size();
    vector<vector<int>> adj(N);
    for (int i = 0; i < M; i++) {
        adj[U[i]].push_back(V[i]);
    }
    vector<int> ans(N);
    for (int i = 0; i < N; i++) {
        vector<int> p;
        vector<bool> vis(N);
        auto dfs = [&](auto dfs, int x) -> int {
            p.push_back(x);
            vis[x] = 1;
            for (int y : adj[x]) {
                if (!vis[y]) {
                    if (dfs(dfs, y) == A[x]) {
                        return A[x];
                    }
                } else {
                    int cyc = 0;
                    for (int i = p.size() - 1; i >= 0; i--) {
                        cyc |= R[p[i]];
                        if (p[i] == y) {
                            break;
                        }
                    }
                    if (A[x] == cyc) {
                        return A[x];
                    }
                }
            }
            vis[x] = 0;
            p.pop_back();
            return 1 - A[x];
        };
        ans[i] = dfs(dfs, i);
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 724 KB 3rd lines differ - on the 141st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 1 ms 212 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2068 ms 1068 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2067 ms 1156 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2056 ms 1120 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 724 KB 3rd lines differ - on the 141st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -