Submission #838508

# Submission time Handle Problem Language Result Execution time Memory
838508 2023-08-27T10:06:40 Z thimote75 Toy Train (IOI17_train) C++14
5 / 100
4 ms 724 KB
#include "train.h"
#include <bits/stdc++.h>

using namespace std;

using idata = vector<int>;
using bdata = vector<bool>;

idata controller, charger;
int N, M;

bdata n0, n1;

idata who_wins(idata _controller, idata _charger, idata u, idata v) {
	N = _controller.size(); M = u.size();

	controller = _controller;
	charger    = _charger;

    n0.resize(N);
    n1.resize(N);

    for (int i = 0; i < M; i ++) {
        if (v[i] == u[i] + 1) n0[u[i]] = 1;
        else n1[u[i]] = 1;
    }

    idata dp(N, 0);

    for (int i = N - 1; i >= 0; i --) {
        bool right = n0[i] == 1;
        bool self  = n1[i] == 1;
        
        idata L;
        if (right) L.push_back(dp[i + 1]);
        if (self)  L.push_back(charger[i]);

        if (controller[i] == 1) {
            int s = 0;
            for (int u : L) s += u;
            dp[i] = min(1, s);
        } else {
            int m = 1e9;
            for (int u : L) m = min(m, u);
            dp[i] = m;
        }
    }
	
	return dp;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 468 KB Output is correct
2 Correct 3 ms 596 KB Output is correct
3 Correct 3 ms 596 KB Output is correct
4 Correct 2 ms 596 KB Output is correct
5 Correct 3 ms 600 KB Output is correct
6 Correct 3 ms 596 KB Output is correct
7 Correct 3 ms 596 KB Output is correct
8 Correct 3 ms 596 KB Output is correct
9 Correct 3 ms 596 KB Output is correct
10 Correct 3 ms 596 KB Output is correct
11 Correct 2 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 724 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 596 KB 3rd lines differ - on the 21st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 724 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 Correct 3 ms 468 KB Output is correct
2 Correct 3 ms 596 KB Output is correct
3 Correct 3 ms 596 KB Output is correct
4 Correct 2 ms 596 KB Output is correct
5 Correct 3 ms 600 KB Output is correct
6 Correct 3 ms 596 KB Output is correct
7 Correct 3 ms 596 KB Output is correct
8 Correct 3 ms 596 KB Output is correct
9 Correct 3 ms 596 KB Output is correct
10 Correct 3 ms 596 KB Output is correct
11 Correct 2 ms 468 KB Output is correct
12 Incorrect 0 ms 212 KB 3rd lines differ - on the 1st token, expected: '0', found: '1'
13 Halted 0 ms 0 KB -