Submission #747031

# Submission time Handle Problem Language Result Execution time Memory
747031 2023-05-23T12:36:51 Z danikoynov Toy Train (IOI17_train) C++14
0 / 100
1490 ms 1532 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;

        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 261 ms 1288 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 4th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 250 ms 1532 KB Output is correct
2 Correct 277 ms 1492 KB Output is correct
3 Correct 297 ms 1440 KB Output is correct
4 Incorrect 1448 ms 1372 KB 3rd lines differ - on the 4557th token, expected: '1', found: '0'
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1060 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 1490 ms 1328 KB 3rd lines differ - on the 3rd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 261 ms 1288 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -