# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
72221 |
2018-08-26T06:06:55 Z |
funcsr |
Toy Train (IOI17_train) |
C++17 |
|
2000 ms |
30464 KB |
#include "train.h"
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <algorithm>
#include <cassert>
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define INF (1LL<<60)
#define _1 first
#define _2 second
using namespace std;
typedef pair<int, int> P;
int N, M;
bool G[15][15];
int dp[14348907];
int seq[15];
int p3[16];
vector<int> who_wins(vector<int> owner, vector<int> color, vector<int> U, vector<int> V) {
N = owner.size(), M = U.size();
assert(N<=15);
rep(i, M) G[U[i]][V[i]] = true;
p3[0] = 1;
for (int i=1; i<=15; i++) p3[i] = p3[i-1]*3;
for (int S=p3[N]-1; S>=0; S--) {
int s = S;
rep(x, N) seq[x] = s%3, s/=3;
int S1 = 0;
for (int x=N-1; x>=0; x--) S1 = S1*3 + (seq[x]?2:0);
rep(x, N) {
bool ok = false;
rep(t, N) if (G[x][t]) {
if (seq[t]) {
if (seq[t] == 2) {
ok = true;
break;
}
}
else {
if (color[t]) {
if ((dp[S1+2*p3[t]]>>t)&1) {
ok = true;
break;
}
}
else {
if ((dp[S+p3[t]]>>t)&1) {
ok = true;
break;
}
}
}
}
if (ok) dp[S] |= 1<<x;
}
}
vector<int> ret(N, 0);
rep(i, N) {
int mask = 0;
if (color[i]) mask = p3[i]*2;
else mask = p3[i];
ret[i] = (dp[mask]>>i)&1;
}
return ret;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
7 ms |
1076 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2062 ms |
30464 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
12 ms |
30464 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
11 ms |
30464 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
11 ms |
30464 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
7 ms |
1076 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |