Submission #747029

# Submission time Handle Problem Language Result Execution time Memory
747029 2023-05-23T12:34:48 Z danikoynov Toy Train (IOI17_train) C++14
0 / 100
2000 ms 1444 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];
vector < int > g[maxn];
int tf, used[maxn];

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

        }
        else
        {
            if (used[u] == 1)
            {
                //cycle[v] = 1;
                int d = v;
                while(d != u)
                {
                    cycle[d] = 1;
                    d = from[d];
                }
                cycle[u] = 1;
            }

        }
    }
    used[v] = 2;
}
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;

        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 257 ms 1172 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 0 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 247 ms 1444 KB Output is correct
2 Correct 272 ms 1392 KB Output is correct
3 Correct 257 ms 1368 KB Output is correct
4 Execution timed out 2061 ms 1296 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2037 ms 1136 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2049 ms 1264 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 257 ms 1172 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -