#include "doll.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
void create_circuit(int M, vector<int> A) {
int N = A.size(), cnt = -1;
vector<int> C(M + 1, -1e9), X, Y, S;
C[0] = A[0];
for (int i = 0; i < N; ++i) {
int cur = C[A[i]];
if(cur == -1e9) C[A[i]] = A[i + 1];
else{
int pre = A[i];
while(cur < 0){
pre = cur;
if(S[-cur - 1]) cur = Y[-cur - 1];
else cur = X[-cur - 1];
S[-pre - 1] ^= 1;
}
if(cur == A[i + 1]) continue;
if(pre == A[i]){
C[A[i]] = cnt--;
X.pb(cur);
Y.pb(A[i + 1]);
S.pb(0);
}else{
if(S[-pre - 1]){
X[-pre - 1] = cnt--;
X.pb(cur);
Y.pb(A[i + 1]);
}else{
Y[-pre - 1] = cnt--;
X.pb(cur);
Y.pb(A[i + 1]);
}
S.pb(1);
}
}
}
if(C[A[N - 1]] == -1e9) C[A[N - 1]] = 0;
else{
int cur = C[A[N - 1]], pre = A[N - 1];
while(cur < 0){
pre = cur;
if(S[-cur - 1]) cur = Y[-cur - 1];
else cur = X[-cur - 1];
S[-pre - 1] ^= 1;
}
if(pre == A[N - 1]){
X.pb(cur);
Y.pb(0);
S.pb(1);
}else{
if(S[-pre - 1]){
X[-pre - 1] = cnt--;
X.pb(cur);
Y.pb(0);
}else{
Y[-pre - 1] = cnt--;
X.pb(cur);
Y.pb(0);
}
}
}
for(auto &x:C) x = (x == -1e9 ? 1 : x), cerr << x << ' ';
cerr << '\n';
for(auto x:X) cerr << x << ' ';
cerr << '\n';
for(auto x:Y) cerr << x << ' ';
cerr << '\n';
answer(C, X, Y);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
257 ms |
2412 KB |
Output is correct |
3 |
Correct |
169 ms |
1896 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
258 ms |
1592 KB |
Output is correct |
6 |
Correct |
250 ms |
2808 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
257 ms |
2412 KB |
Output is correct |
3 |
Correct |
169 ms |
1896 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
258 ms |
1592 KB |
Output is correct |
6 |
Correct |
250 ms |
2808 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Incorrect |
481 ms |
5244 KB |
state 'Y' |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
257 ms |
2412 KB |
Output is correct |
3 |
Correct |
169 ms |
1896 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
258 ms |
1592 KB |
Output is correct |
6 |
Correct |
250 ms |
2808 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Incorrect |
481 ms |
5244 KB |
state 'Y' |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
wrong motion |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
wrong motion |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
wrong motion |
2 |
Halted |
0 ms |
0 KB |
- |