답안 #747027

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
747027 2023-05-23T12:30:41 Z danikoynov 장난감 기차 (IOI17_train) C++14
0 / 100
1400 ms 1352 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)
{
    used[v] = 1;
    for (int u : g[v])
    {
        if (!used[u])
        {
            dfs(u);

        }
        else
        {
            if (used[u] == 1)
            {
                cycle[v] = 1;
            }
            else
                if (cycle[u])
                cycle[v] = 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;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 245 ms 980 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 Grader output
1 Correct 198 ms 1352 KB Output is correct
2 Correct 235 ms 1308 KB Output is correct
3 Correct 185 ms 1272 KB Output is correct
4 Correct 1400 ms 1240 KB Output is correct
5 Incorrect 1022 ms 1228 KB 3rd lines differ - on the 11th token, expected: '0', found: '1'
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1050 ms 1080 KB 3rd lines differ - on the 696th token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1375 ms 1216 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 245 ms 980 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -