Submission #227685

# Submission time Handle Problem Language Result Execution time Memory
227685 2020-04-28T12:56:29 Z AaronNaidu Toy Train (IOI17_train) C++14
15 / 100
2000 ms 1408 KB
#include <bits/stdc++.h>
using namespace std;

vector<int> a, r, f;
vector<int> graph[5000];
vector<bool> visited;

bool cycleTime(int node, int orig) {
    if (r[node])
    {
        return true;
    }
    if (node == orig)
    {
        return false;
    }
    return cycleTime(f[node], orig);
}

bool doesAWin(int x) {
    if (visited[x])
    {
        return cycleTime(f[x], x);
    }
    visited[x] = true;
    bool toRet;
    if (a[x])
    {
        toRet = false;
        for (auto i : graph[x])
        {
            f[x] = i;
            toRet = toRet or doesAWin(i);
            f[x] = -1;
        }
    }
    else
    {
        toRet = true;
        for (auto i : graph[x])
        {
            f[x] = i;
            toRet = toRet and doesAWin(i);
            f[x] = -1;
        }
    }
    visited[x] = false;
    return toRet;
}

vector<int> who_wins(vector<int> la, vector<int> lr, vector<int> lu, vector<int> lv) {
    a = la;
    r = lr;
    for (int i = 0; i < lu.size(); i++)
    {
        graph[lu[i]].push_back(lv[i]);
    }
    for (int i = 0; i < a.size(); i++)
    {
        f.push_back(-1);
        visited.push_back(false);
    }
    vector<int> toRet;
    for (int i = 0; i < a.size(); i++)
    {
        toRet.push_back(doesAWin(i));
    }
    return toRet;
}

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:54:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < lu.size(); i++)
                     ~~^~~~~~~~~~~
train.cpp:58:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < a.size(); i++)
                     ~~^~~~~~~~~~
train.cpp:64:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < a.size(); i++)
                     ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 10 ms 1024 KB Output is correct
2 Correct 9 ms 1024 KB Output is correct
3 Correct 10 ms 1024 KB Output is correct
4 Correct 10 ms 1024 KB Output is correct
5 Correct 9 ms 1024 KB Output is correct
6 Correct 9 ms 1024 KB Output is correct
7 Correct 9 ms 1024 KB Output is correct
8 Correct 9 ms 1024 KB Output is correct
9 Correct 8 ms 1024 KB Output is correct
10 Correct 9 ms 1024 KB Output is correct
11 Correct 8 ms 896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 512 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 512 KB Output is correct
18 Correct 5 ms 512 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2085 ms 1408 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2093 ms 1280 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2093 ms 1408 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 1024 KB Output is correct
2 Correct 9 ms 1024 KB Output is correct
3 Correct 10 ms 1024 KB Output is correct
4 Correct 10 ms 1024 KB Output is correct
5 Correct 9 ms 1024 KB Output is correct
6 Correct 9 ms 1024 KB Output is correct
7 Correct 9 ms 1024 KB Output is correct
8 Correct 9 ms 1024 KB Output is correct
9 Correct 8 ms 1024 KB Output is correct
10 Correct 9 ms 1024 KB Output is correct
11 Correct 8 ms 896 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 512 KB Output is correct
15 Correct 5 ms 512 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 512 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 512 KB Output is correct
26 Correct 5 ms 384 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
28 Correct 5 ms 512 KB Output is correct
29 Correct 5 ms 512 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 5 ms 384 KB Output is correct
32 Execution timed out 2085 ms 1408 KB Time limit exceeded
33 Halted 0 ms 0 KB -