Submission #1024999

# Submission time Handle Problem Language Result Execution time Memory
1024999 2024-07-16T13:57:10 Z c2zi6 Toy Train (IOI17_train) C++14
5 / 100
5 ms 1372 KB
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define replr(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define reprl(i, a, b) for (int i = int(a); i >= int(b); --i)
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define mkp(a, b) make_pair(a, b)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VPI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<VPI> VVPI;
typedef pair<ll, ll> PLL;
typedef vector<ll> VL;
typedef vector<PLL> VPL;
typedef vector<VL> VVL;
typedef vector<VVL> VVVL;
typedef vector<VPL> VVPL;
template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;}
template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;}
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T>
using indset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#include "train.h"

namespace TEST1 {
    bool check(VI U, VI V) {
        rep(i, U.size()) if (V[i] != U[i] && V[i] != U[i]+1) return false;
        return true;
    }
    VI solve(VVI gp, VI owner, VI charge) {
        int n = gp.size();
        VI ans(n);
        reprl(u, n-1, 0) {
            if (gp[u].size() == 2) {
                if (owner[u] == 1) {
                    ans[u] = 0;
                    if (charge[u] == 1) ans[u] = 1;
                    else for (int v : gp[u]) if (v != u) {
                        if (ans[v] == 1) ans[u] = 1;
                    }
                } else {
                    ans[u] = 1;
                    if (charge[u] == 0) ans[u] = 0;
                    else for (int v : gp[u]) if (v != u) {
                        if (ans[v] == 0) ans[u] = 0;
                    }
                }
            } else if (gp[u].size()) {
                if (gp[u][0] == u) {
                    ans[u] = (charge[u]);
                } else {
                    ans[u] = ans[gp[u][0]];
                }
            }
        }
        return ans;
    }
};
namespace TEST2 {
};
namespace TEST3 {
};
namespace TEST4 {
};

VI who_wins(VI owner, VI charge, VI U, VI V) {
    int n = owner.size();
    int m = U.size();
    VVI gp(n);
    rep(i, m) gp[U[i]].pb(V[i]);
    if (TEST1::check(U, V)) return TEST1::solve(gp, owner, charge);

	return {3, 1, 4};
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1112 KB Output is correct
2 Correct 5 ms 1116 KB Output is correct
3 Correct 4 ms 1192 KB Output is correct
4 Correct 3 ms 1116 KB Output is correct
5 Correct 3 ms 1084 KB Output is correct
6 Correct 4 ms 1116 KB Output is correct
7 Correct 3 ms 1116 KB Output is correct
8 Correct 3 ms 1116 KB Output is correct
9 Correct 3 ms 1116 KB Output is correct
10 Correct 2 ms 1116 KB Output is correct
11 Correct 2 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB WA in grader: Wrong returned array size
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 1372 KB WA in grader: Wrong returned array size
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 1116 KB WA in grader: Wrong returned array size
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 1372 KB WA in grader: Wrong returned array size
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1112 KB Output is correct
2 Correct 5 ms 1116 KB Output is correct
3 Correct 4 ms 1192 KB Output is correct
4 Correct 3 ms 1116 KB Output is correct
5 Correct 3 ms 1084 KB Output is correct
6 Correct 4 ms 1116 KB Output is correct
7 Correct 3 ms 1116 KB Output is correct
8 Correct 3 ms 1116 KB Output is correct
9 Correct 3 ms 1116 KB Output is correct
10 Correct 2 ms 1116 KB Output is correct
11 Correct 2 ms 1116 KB Output is correct
12 Incorrect 0 ms 348 KB WA in grader: Wrong returned array size
13 Halted 0 ms 0 KB -