This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "lockpicking.h"
#include <bits/stdc++.h>
using namespace std;
int M;
vector<int> a, b;
vector<vector<int>> s, t;
void construct_card(int N, std::vector<int> A, std::vector<std::vector<int>> S)
{
a = A, s = S;
M = N * N;
b.resize(M);
t.assign(M, vector<int>(2));
for(int c = 0; c < N; c ++)
{
for (int j = c * N; j < (c + 1) * N; j ++)
{
b[j] = a[j % N];
t[j][b[j]] = c * N + s[j % N][b[j]];
t[j][1 - b[j]] = -1;
}
}
for(int i0 = 1; i0 < N; i0 ++)
{
int i = i0, j = 0;
for (int cnt = 0; cnt < M; cnt ++)
{
if(b[j] == a[i])
{
j = t[j][b[j]];
i = s[i][a[i]];
}
else
{
if (t[j][a[i]] == -1)
{
int nxti = s[i][b[j]];
t[j][a[i]] = i0 * N + nxti;
break;
}
else
{
j = t[j][a[i]];
i = s[i][1 - a[i]];
}
}
}
}
for(int j = 0; j < M; j ++)
{
t[j][0] = max(0, t[j][0]);
t[j][1] = max(0, t[j][1]);
}
define_states(M, b, t, 0);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |