Submission #1064185

# Submission time Handle Problem Language Result Execution time Memory
1064185 2024-08-18T10:05:01 Z Ignut Toy Train (IOI17_train) C++17
5 / 100
5 ms 1116 KB
// Ignut

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const int N = 5555;
int n, m;

vector<int> a, r;

vector<int> g[N];

bool ans = false;

int used[N];
bool good[N];

void dfs(int v) {
    used[v] = true;
    ans |= good[v];
    if (ans) return;
    for (int to : g[v])
        if (!used[to])
            dfs(to);
}

void dfs1(int v, int st) {
    if (good[st]) return;
    used[v] = true;
    for (int to : g[v]) {
        if (to == st) {
            good[st] = true; return;
        }
        if (!used[to]) dfs1(to, st);
    }
}

void dfs2(int v, int st) {
    if (good[st]) return;
    used[v] = true;
    for (int to : g[v]) {
        if (r[to] == 1) continue;
        if (to == st) {
            good[st] = true; return;
        }
        if (!used[to]) dfs2(to, st);
    }
}

vector<int> who_wins(vector<int> A, vector<int> R, vector<int> u, vector<int> v) {
    n = A.size(), m = u.size();
    a = A, r = R;
    bool canLoop[n] = {};
    bool canRight[n] = {};
    for (int i = 0; i < m; i ++) {
        if (v[i] == u[i]) canLoop[u[i]] = true;
        if (v[i] == u[i] + 1) canRight[u[i]] = true;
    }

    vector<int> res;
    for (int s = 0; s < n; s ++) {
        int v = s;
        bool ans;
        while (true) {
            if (!canRight[v]) {
                ans = (r[v] == 1);
                break;
            }
            if (canLoop[v] && r[v] && a[v]) {
                ans = true; break;
            }
            if (canLoop[v] && !r[v] && !a[v]) {
                ans = false; break;
            }
            v ++;
        }
        res.push_back(ans);
    }
    return res;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 860 KB Output is correct
2 Correct 2 ms 860 KB Output is correct
3 Correct 2 ms 748 KB Output is correct
4 Correct 2 ms 860 KB Output is correct
5 Correct 3 ms 860 KB Output is correct
6 Correct 2 ms 860 KB Output is correct
7 Correct 2 ms 860 KB Output is correct
8 Correct 2 ms 860 KB Output is correct
9 Correct 2 ms 740 KB Output is correct
10 Correct 2 ms 860 KB Output is correct
11 Correct 2 ms 860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 1116 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 1112 KB 3rd lines differ - on the 21st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 1116 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 2 ms 860 KB Output is correct
2 Correct 2 ms 860 KB Output is correct
3 Correct 2 ms 748 KB Output is correct
4 Correct 2 ms 860 KB Output is correct
5 Correct 3 ms 860 KB Output is correct
6 Correct 2 ms 860 KB Output is correct
7 Correct 2 ms 860 KB Output is correct
8 Correct 2 ms 860 KB Output is correct
9 Correct 2 ms 740 KB Output is correct
10 Correct 2 ms 860 KB Output is correct
11 Correct 2 ms 860 KB Output is correct
12 Incorrect 0 ms 348 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
13 Halted 0 ms 0 KB -