#include "doll.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long double ld;
typedef vector<vector<ll>> vll;
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define ROF(i, a, b) for(int i = a; i >= b; i--)
#define pb push_back
#define ms memset
#define fi first
#define se second
const int mxN = 1e6+1;
int cur = 1; vi X(mxN),Y(mxN),C;
void build(int i, vi nxt){
if (nxt.size()==2){
X[i-1] = nxt[0];
Y[i-1] = nxt[1];
return;
}
int len = nxt.size();
if (len % 2 == 0){
X[i-1] = -cur; cur++;
vi Nxt;
for (int j = 0; j < len; j+=2) Nxt.pb(nxt[j]);
build(cur-1,Nxt); Nxt.clear();
for (int j = 1; j < len; j+=2) Nxt.pb(nxt[j]);
Y[i-1] = -cur; cur++;
build(cur-1,Nxt);
}else{
X[i-1] = -cur; cur++;
vi Nxt;
for (int j = 0; j < len-1; j+=2) Nxt.pb(nxt[j]);
Nxt.pb(-i);
build(cur-1,Nxt); Nxt.clear();
for (int j = 1; j < len; j+=2) Nxt.pb(nxt[j]);
Y[i-1] = -cur; cur++;
Nxt.pb(nxt[len-1]);
build(cur-1,Nxt);
}
}
void create_circuit(int M, vi A) {
int N = A.size();
C.resize(M+1);
C[0] = A[0];
if (A.size()==1){
answer(C,{},{}); return;
}
FOR(i,1,M+1) C[i] = -1;
cur++;
vi nxt;
FOR(i,1,A.size()) nxt.pb(A[i]);
nxt.pb(0);
build(1,nxt);
vi x(cur-1), y(cur-1);
FOR(i,0,cur-1){
x[i]=X[i]; y[i]=Y[i];
}
answer(C, x, y);
}
Compilation message
doll.cpp: In function 'void create_circuit(int, vi)':
doll.cpp:10:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
10 | #define FOR(i, a, b) for(int i = a; i < b; i++)
......
57 | FOR(i,1,A.size()) nxt.pb(A[i]);
| ~~~~~~~~~~~~
doll.cpp:57:3: note: in expansion of macro 'FOR'
57 | FOR(i,1,A.size()) nxt.pb(A[i]);
| ^~~
doll.cpp:48:7: warning: unused variable 'N' [-Wunused-variable]
48 | int N = A.size();
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
8024 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
8024 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
8024 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
8280 KB |
Output is correct |
2 |
Correct |
2 ms |
8028 KB |
Output is correct |
3 |
Correct |
4 ms |
8100 KB |
Output is correct |
4 |
Correct |
3 ms |
8028 KB |
Output is correct |
5 |
Correct |
3 ms |
8028 KB |
Output is correct |
6 |
Correct |
3 ms |
8028 KB |
Output is correct |
7 |
Correct |
2 ms |
8284 KB |
Output is correct |
8 |
Correct |
2 ms |
8280 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
2 ms |
8028 KB |
Output is partially correct |
2 |
Correct |
41 ms |
14392 KB |
Output is correct |
3 |
Partially correct |
76 ms |
17452 KB |
Output is partially correct |
4 |
Partially correct |
76 ms |
19636 KB |
Output is partially correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
2 ms |
8028 KB |
Output is partially correct |
2 |
Correct |
41 ms |
14392 KB |
Output is correct |
3 |
Partially correct |
76 ms |
17452 KB |
Output is partially correct |
4 |
Partially correct |
76 ms |
19636 KB |
Output is partially correct |
5 |
Partially correct |
79 ms |
19892 KB |
Output is partially correct |
6 |
Partially correct |
75 ms |
19896 KB |
Output is partially correct |
7 |
Partially correct |
76 ms |
19900 KB |
Output is partially correct |
8 |
Partially correct |
73 ms |
19896 KB |
Output is partially correct |
9 |
Partially correct |
66 ms |
17452 KB |
Output is partially correct |
10 |
Partially correct |
72 ms |
19892 KB |
Output is partially correct |
11 |
Partially correct |
72 ms |
19648 KB |
Output is partially correct |
12 |
Partially correct |
67 ms |
17352 KB |
Output is partially correct |
13 |
Correct |
41 ms |
14776 KB |
Output is correct |
14 |
Partially correct |
69 ms |
17348 KB |
Output is partially correct |
15 |
Partially correct |
70 ms |
17416 KB |
Output is partially correct |
16 |
Partially correct |
4 ms |
8540 KB |
Output is partially correct |
17 |
Correct |
44 ms |
14528 KB |
Output is correct |
18 |
Correct |
41 ms |
14524 KB |
Output is correct |
19 |
Partially correct |
69 ms |
17440 KB |
Output is partially correct |
20 |
Partially correct |
73 ms |
19644 KB |
Output is partially correct |
21 |
Partially correct |
72 ms |
19644 KB |
Output is partially correct |
22 |
Partially correct |
83 ms |
19648 KB |
Output is partially correct |