Submission #747021

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

void dfs(int v)
{
    for (int u : g[v])
    {
        if (!used[u])
        {
            dfs(u);
            if (cycle[u])
                cycle[v] = 1;
        }
        else
        {
            if (used[u] == 1)
            {
                cycle[v] = 1;
            }
            else
            {
                if (cycle[u])
                    cycle[v] = 1;
            }
        }
    }
}
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);
    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;
}

Compilation message

train.cpp: In function 'std::vector<int> who_wins(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
train.cpp:52:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   52 |         for (int j = 0; j < n; j ++)
      |         ^~~
train.cpp:55:13: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   55 |             dfs(i);
      |             ^~~
# Verdict Execution time Memory Grader output
1 Runtime error 133 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 130 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 157 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 122 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 130 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 133 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -