Submission #1063492

# Submission time Handle Problem Language Result Execution time Memory
1063492 2024-08-17T19:26:13 Z Zicrus Toy Train (IOI17_train) C++17
11 / 100
1347 ms 2008 KB
#include <bits/stdc++.h>
#include "train.h"
using namespace std;

typedef long long ll;

ll n;
vector<int> a, r, res;
vector<vector<ll>> adj, revAdj;
vector<bool> vst;

bool dfsCyc(ll cur, ll root) {
    vst[cur] = true;
    for (auto &e : adj[cur]) {
        if (e == root) return true;
        if (vst[e] || r[e]) continue;
        if (dfsCyc(e, root)) return true;
    }
    return false;
}

void dfsRes(ll cur) {
    vst[cur] = true;
    res[cur] = 0;
    for (auto &e : revAdj[cur]) {
        if (vst[e]) continue;
        dfsRes(e);
    }
}

vector<int> who_wins(vector<int> A, vector<int> R, vector<int> u, vector<int> v) {
    n = A.size();
    a = A; r = R;
	res = vector<int>(n, 1);
	vst = vector<bool>(n);
    adj = vector<vector<ll>>(n);
    revAdj = vector<vector<ll>>(n);
    for (int i = 0; i < u.size(); i++) {
        adj[u[i]].push_back(v[i]);
        revAdj[v[i]].push_back(u[i]);
    }

    for (int i = 0; i < n; i++) {
        if (r[i]) continue;
        vst = vector<bool>(n);
        if (dfsCyc(i, i)) {
	        vst = vector<bool>(n);
            dfsRes(i);
        }
    }

	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:38:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     for (int i = 0; i < u.size(); i++) {
      |                     ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 1364 KB 3rd lines differ - on the 14th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB 3rd lines differ - on the 2nd token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 127 ms 1880 KB Output is correct
2 Correct 135 ms 1876 KB Output is correct
3 Correct 136 ms 1856 KB Output is correct
4 Incorrect 871 ms 1828 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1444 KB Output is correct
2 Correct 71 ms 1604 KB Output is correct
3 Correct 97 ms 1624 KB Output is correct
4 Correct 73 ms 1708 KB Output is correct
5 Correct 243 ms 1624 KB Output is correct
6 Correct 219 ms 1884 KB Output is correct
7 Correct 174 ms 1868 KB Output is correct
8 Correct 67 ms 1820 KB Output is correct
9 Correct 5 ms 1628 KB Output is correct
10 Correct 6 ms 1884 KB Output is correct
11 Correct 5 ms 1884 KB Output is correct
12 Correct 6 ms 1884 KB Output is correct
13 Correct 502 ms 2008 KB Output is correct
14 Correct 224 ms 1840 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1347 ms 1864 KB 3rd lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 1364 KB 3rd lines differ - on the 14th token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -