#include "doll.h"
#include<bits/stdc++.h>
using namespace std;
#define in insert
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
// #define int long long
typedef long long ll;
typedef vector<int> vi;
typedef set<int> si;
typedef multiset<int> msi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
void create_circuit(int m, std::vector<int> a) {
int n = a.size();
vector<int> c(m + 1, 0), x, y;
vector<vector<int>> g(m + 1);
a.pb(0);
g[0].pb(a[0]);
for(int i = 0; i < n; i++) {
g[a[i]].pb(a[i + 1]);
}
auto add = [&](int X, int Y) -> int {
x.pb(X);
y.pb(Y);
return -(int)x.size();
};
for(int i = 0; i <= m; i++) {
int sz = g[i].size();
if(sz == 0) continue;
if(sz == 1) {
c[i] = g[i][0];
continue;
}
int tmp = 1;
while(tmp * 2 < sz) tmp *= 2;
while(g[i].size() < tmp * 2) g[i].pb(0);
while(g[i].size() > 1) {
vector<int> nwg;
for(int j = 0; j < g[i].size(); j += 2) {
nwg.pb(add(g[i][j], g[i][j + 1]));
}
swap(nwg, g[i]);
}
c[i] = g[i][0];
}
answer(c, x, y);
}
Compilation message
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:46:21: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
46 | while(g[i].size() < tmp * 2) g[i].pb(0);
| ~~~~~~~~~~~~^~~~~~~~~
doll.cpp:49:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
49 | for(int j = 0; j < g[i].size(); j += 2) {
| ~~^~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
20 ms |
6592 KB |
Output is correct |
3 |
Correct |
16 ms |
5440 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
11 ms |
3796 KB |
Output is correct |
6 |
Correct |
24 ms |
7980 KB |
Output is correct |
7 |
Correct |
1 ms |
236 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
20 ms |
6592 KB |
Output is correct |
3 |
Correct |
16 ms |
5440 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
11 ms |
3796 KB |
Output is correct |
6 |
Correct |
24 ms |
7980 KB |
Output is correct |
7 |
Correct |
1 ms |
236 KB |
Output is correct |
8 |
Correct |
34 ms |
7480 KB |
Output is correct |
9 |
Correct |
36 ms |
8892 KB |
Output is correct |
10 |
Correct |
53 ms |
11652 KB |
Output is correct |
11 |
Correct |
1 ms |
296 KB |
Output is correct |
12 |
Correct |
1 ms |
296 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
20 ms |
6592 KB |
Output is correct |
3 |
Correct |
16 ms |
5440 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
11 ms |
3796 KB |
Output is correct |
6 |
Correct |
24 ms |
7980 KB |
Output is correct |
7 |
Correct |
1 ms |
236 KB |
Output is correct |
8 |
Correct |
34 ms |
7480 KB |
Output is correct |
9 |
Correct |
36 ms |
8892 KB |
Output is correct |
10 |
Correct |
53 ms |
11652 KB |
Output is correct |
11 |
Correct |
1 ms |
296 KB |
Output is correct |
12 |
Correct |
1 ms |
296 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Incorrect |
78 ms |
11280 KB |
wrong motion |
15 |
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 |
1 ms |
212 KB |
wrong motion |
2 |
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 |
- |