#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fo(i, n) for(ll i = 0; i<(n); i++)
#define pb push_back
#define F first
#define S second
#define deb(x) cout << #x << " = " << (x) << endl
#define deb2(x, y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
typedef vector<ll> vl;
typedef vector<vl> vvl;
// void answer(std::vector<int> C, std::vector<int> X, std::vector<int> Y){
// }
void answer(std::vector<int> C, std::vector<int> X, std::vector<int> Y);
void create_circuit(int M, std::vector<int> A){
vvl adj(M+1);
ll n = A.size();
adj[0].pb(A[0]);
fo(i, n){
if(i<n-1) adj[A[i]].pb(A[i+1]);
else adj[A[i]].pb(0);
}
ll cou = 0;
vector<int> c, x, y;
fo(i, M+1){
cou = x.size();
ll co = 0;
if(adj[i].size() == 0){
c.pb(i);
continue;
}
else if(adj[i].size() == 1){
c.pb(adj[i][0]);
continue;
}
c.pb(-cou-1);
ll am = adj[i].size();
ll ext = 1;
while(ext<am) ext*=2ll;
ll am2 = ext-am;
vl order(ext*2);
vl state(ext, 0);
fo(j, ext){
ll current = 1;
while(current<ext){
ll sta = state[current];
state[current] = !state[current];
current*=2;
if(sta)current++;
}
if(j<am2) order[current] = (-cou-1);
else order[current] = (adj[i][co++]);
// deb2(current, order[current]);
}
co= 0;
fo(i, ext){
if(!i) continue;
if(i*2<ext){
x.pb(-cou-i*2);
y.pb(-cou-i*2-1);
}else{
x.pb(order[i*2]);
y.pb(order[i*2+1]);
}
}
}
// fo(i, c.size()){
// deb(c[i]);
// }
// fo(i, x.size()){
// deb2(x[i], y[i]);
// }
answer(c, x, y);
}
// int main(){
// vector<int> st = {1, 2, 1, 2, 1, 2};
// create_circuit(2, st);
// return 0;
// }
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
18 ms |
6620 KB |
Output is correct |
3 |
Correct |
14 ms |
5084 KB |
Output is correct |
4 |
Correct |
1 ms |
600 KB |
Output is correct |
5 |
Correct |
8 ms |
4048 KB |
Output is correct |
6 |
Correct |
21 ms |
7900 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
18 ms |
6620 KB |
Output is correct |
3 |
Correct |
14 ms |
5084 KB |
Output is correct |
4 |
Correct |
1 ms |
600 KB |
Output is correct |
5 |
Correct |
8 ms |
4048 KB |
Output is correct |
6 |
Correct |
21 ms |
7900 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
32 ms |
7248 KB |
Output is correct |
9 |
Correct |
30 ms |
8656 KB |
Output is correct |
10 |
Correct |
49 ms |
11036 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
18 ms |
6620 KB |
Output is correct |
3 |
Correct |
14 ms |
5084 KB |
Output is correct |
4 |
Correct |
1 ms |
600 KB |
Output is correct |
5 |
Correct |
8 ms |
4048 KB |
Output is correct |
6 |
Correct |
21 ms |
7900 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
32 ms |
7248 KB |
Output is correct |
9 |
Correct |
30 ms |
8656 KB |
Output is correct |
10 |
Correct |
49 ms |
11036 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
62 ms |
12800 KB |
Output is correct |
15 |
Correct |
33 ms |
7644 KB |
Output is correct |
16 |
Correct |
47 ms |
11528 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
65 ms |
13336 KB |
Output is correct |
21 |
Correct |
1 ms |
344 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 |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
348 KB |
Output is partially correct |
2 |
Correct |
33 ms |
7844 KB |
Output is correct |
3 |
Partially correct |
66 ms |
12996 KB |
Output is partially correct |
4 |
Partially correct |
63 ms |
14528 KB |
Output is partially correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
348 KB |
Output is partially correct |
2 |
Correct |
33 ms |
7844 KB |
Output is correct |
3 |
Partially correct |
66 ms |
12996 KB |
Output is partially correct |
4 |
Partially correct |
63 ms |
14528 KB |
Output is partially correct |
5 |
Partially correct |
69 ms |
15028 KB |
Output is partially correct |
6 |
Partially correct |
76 ms |
15540 KB |
Output is partially correct |
7 |
Partially correct |
66 ms |
15492 KB |
Output is partially correct |
8 |
Partially correct |
70 ms |
15884 KB |
Output is partially correct |
9 |
Partially correct |
53 ms |
11280 KB |
Output is partially correct |
10 |
Partially correct |
88 ms |
18324 KB |
Output is partially correct |
11 |
Partially correct |
71 ms |
16564 KB |
Output is partially correct |
12 |
Partially correct |
49 ms |
10856 KB |
Output is partially correct |
13 |
Partially correct |
48 ms |
10176 KB |
Output is partially correct |
14 |
Partially correct |
44 ms |
10184 KB |
Output is partially correct |
15 |
Partially correct |
45 ms |
9916 KB |
Output is partially correct |
16 |
Partially correct |
1 ms |
604 KB |
Output is partially correct |
17 |
Partially correct |
36 ms |
9076 KB |
Output is partially correct |
18 |
Partially correct |
37 ms |
9060 KB |
Output is partially correct |
19 |
Partially correct |
39 ms |
9408 KB |
Output is partially correct |
20 |
Partially correct |
57 ms |
12476 KB |
Output is partially correct |
21 |
Partially correct |
67 ms |
14428 KB |
Output is partially correct |
22 |
Partially correct |
53 ms |
11620 KB |
Output is partially correct |