Submission #747033

# Submission time Handle Problem Language Result Execution time Memory
747033 2023-05-23T12:37:51 Z danikoynov Toy Train (IOI17_train) C++14
0 / 100
1457 ms 1496 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

const int maxn = 5010;
int n, m, a[maxn], r[maxn], cycle[maxn], nxt[maxn], from[maxn], rem[maxn], add[maxn];
vector < int > g[maxn];
int tf, used[maxn];

int dfs(int v)
{
    used[v] = 1;
    int sum = 0;
    for (int u : g[v])
    {
        if (!used[u])
        {
            from[u] = v;
            sum += dfs(u);

        }
        else
        {
            if (used[u] == 1)
            {
                //cycle[v] = 1;
                sum ++;
                if (from[u] != -1)
                rem[from[u]] ++;
            }

        }
    }
    sum -= rem[v];
    if (sum > 0)
        cycle[v] = 1;
    used[v] = 2;
    return sum;
}
vector<int> who_wins(vector<int> A, vector<int> R, vector<int> U, vector<int> V)
{
    n = A.size();
    m = U.size();
    for (int i = 0; i < n; i ++)
        a[i] = A[i];
    for (int i = 0; i < n; i ++)
        r[i] = R[i];

    for (int i = 0; i < m; i ++)
    {
        g[U[i]].push_back(V[i]);
    }

    vector < int > res(n, 0);
    for (int i = 0; i < n; i ++)
    {
        for (int j = 0; j < n; j ++)
            used[j] = 0, cycle[j] = 0, rem[j] = 0;

        from[i] = -1;
        dfs(i);
        for (int j = 0; j < n; j ++)
            if (cycle[j] && r[j])
                res[i] = 1;
    }

    return res;
}
# Verdict Execution time Memory Grader output
1 Incorrect 313 ms 1280 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 1 ms 340 KB 3rd lines differ - on the 8th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 258 ms 1492 KB Output is correct
2 Correct 273 ms 1476 KB Output is correct
3 Correct 295 ms 1364 KB Output is correct
4 Correct 1457 ms 1496 KB Output is correct
5 Correct 1059 ms 1316 KB Output is correct
6 Correct 750 ms 1188 KB Output is correct
7 Correct 668 ms 1368 KB Output is correct
8 Incorrect 348 ms 1380 KB 3rd lines differ - on the 27th token, expected: '1', found: '0'
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1092 ms 1204 KB 3rd lines differ - on the 696th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1447 ms 1356 KB 3rd lines differ - on the 2nd token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 313 ms 1280 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -