#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 "doll.h"
namespace TEST2 {
void solve(int M, VI A) {
VI C, X, Y;
C = VI(M+1);
VI cnt(M+1);
for (int x : A) cnt[x]++;
VI sw(M+1, -1);
int u = 0;
for (int v : A) {
if (cnt[u] == 2) {
if (sw[u] == -1) {
sw[u] = X.size();
C[u] = -(sw[u]+1);
X.pb(0);
Y.pb(0);
X[sw[u]] = v;
} else {
Y[sw[u]] = v;
}
} else {
C[u] = v;
}
u = v;
}
answer(C, X, Y);
}
};
namespace TEST5 {
void solve(int M, VI A) {
int N = A.size();
VI C;
VI X;
VI Y;
if (A.size() == 1) {
C.pb(1);
C.pb(0);
answer(C, X, Y);
return;
}
C.pb(1);
C.pb(-1);
int s = 0;
while ((1<<s) < N) s++;
replr(i, 2, s+1) {
X.pb(-1);
Y.pb(-i);
}
Y.back() = 0;
int n = N-1;
rep(i, s) {
if (n & (1<<i)) {
X[s-1-i] = 1;
}
}
answer(C, X, Y);
}
};
namespace TEST3 {
void solve(int M, VI A) {
VI C, X, Y;
C = VI(M+1);
VI cnt(M+1);
for (int x : A) cnt[x]++;
VI sw(M+1, -1);
VI turn(M+1);
auto trans = [&](int x) {
return -(x+1);
};
int u = 0;
for (int v : A) {
if (cnt[u] == 4) {
if (turn[u] == 0) {
sw[u] = X.size();
C[u] = trans(sw[u]);
X.pb(0), Y.pb(0);
X.pb(0), Y.pb(0);
X.pb(0), Y.pb(0);
X[sw[u]] = trans(sw[u]+1);
Y[sw[u]] = trans(sw[u]+2);
}
if (turn[u] == 0) {
X[sw[u]+1] = v;
} else if (turn[u] == 1) {
X[sw[u]+2] = v;
} else if (turn[u] == 2) {
Y[sw[u]+1] = v;
} else if (turn[u] == 3) {
Y[sw[u]+2] = v;
}
} else if (cnt[u] == 3) {
if (turn[u] == 0) {
sw[u] = X.size();
C[u] = trans(sw[u]);
X.pb(0), Y.pb(0);
X.pb(0), Y.pb(0);
X.pb(0), Y.pb(0);
X[sw[u]] = trans(sw[u]+1);
Y[sw[u]] = trans(sw[u]+2);
X[sw[u]+1] = trans(sw[u]);
}
if (turn[u] == 0) {
X[sw[u]+2] = v;
} else if (turn[u] == 1) {
Y[sw[u]+1] = v;
} else if (turn[u] == 2) {
Y[sw[u]+2] = v;
}
} else if (cnt[u] == 2) {
if (turn[u] == 0) {
sw[u] = X.size();
C[u] = trans(sw[u]);
X.pb(0), Y.pb(0);
}
if (turn[u] == 0) {
X[sw[u]] = v;
} else if (turn[u] == 1) {
Y[sw[u]] = v;
}
} else {
C[u] = v;
}
turn[u]++;
u = v;
}
answer(C, X, Y);
}
};
void create_circuit(int M, VI A) {
if (M == 1) TEST5::solve(M, A);
else TEST3::solve(M, A);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
11 ms |
3932 KB |
Output is correct |
3 |
Correct |
15 ms |
3160 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
6 ms |
2652 KB |
Output is correct |
6 |
Correct |
13 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
11 ms |
3932 KB |
Output is correct |
3 |
Correct |
15 ms |
3160 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
6 ms |
2652 KB |
Output is correct |
6 |
Correct |
13 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
22 ms |
6104 KB |
Output is correct |
9 |
Correct |
23 ms |
6100 KB |
Output is correct |
10 |
Correct |
34 ms |
9156 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
11 ms |
3932 KB |
Output is correct |
3 |
Correct |
15 ms |
3160 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
6 ms |
2652 KB |
Output is correct |
6 |
Correct |
13 ms |
4444 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
22 ms |
6104 KB |
Output is correct |
9 |
Correct |
23 ms |
6100 KB |
Output is correct |
10 |
Correct |
34 ms |
9156 KB |
Output is correct |
11 |
Correct |
0 ms |
344 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
44 ms |
10436 KB |
Output is correct |
15 |
Correct |
24 ms |
5836 KB |
Output is correct |
16 |
Correct |
36 ms |
8900 KB |
Output is correct |
17 |
Correct |
0 ms |
344 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
38 ms |
9636 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
wrong motion |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
8 ms |
2908 KB |
Output is correct |
3 |
Correct |
8 ms |
2752 KB |
Output is correct |
4 |
Correct |
13 ms |
4436 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
8 ms |
2908 KB |
Output is correct |
3 |
Correct |
8 ms |
2752 KB |
Output is correct |
4 |
Correct |
13 ms |
4436 KB |
Output is correct |
5 |
Incorrect |
17 ms |
5212 KB |
wrong motion |
6 |
Halted |
0 ms |
0 KB |
- |