#include "doll.h"
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define mp make_pair
#define fi first
#define se second
#define pb push_back
typedef long long ll;
const int maxn5 = 1e6 + 10;
int newnode = 0;
vector <int> c, x, y;
vector <pair<int, int>> av[maxn5];
int build(int n){
int rt = newnode++;
x.pb(0);
y.pb(0);
if(n == 2){
av[rt].pb({rt, 0});
av[rt].pb({rt, 1});
return rt;
}
int a = (n / 2);
if(n & 1)
a++;
int r1 = build(a), r2 = build(a);
x[rt] = -(r1 + 1);
y[rt] = -(r2 + 1);
//cout << "building " << n << ' ' << rt << ' ' << r1 << ' ' << r2 << endl;
for(int i = 0; i < a; i++){
if(n & 1){
if(av[r1][i].se)
y[av[r1][i].fi] = -(rt + 1);
else
x[av[r1][i].fi] = -(rt + 1);
}
else
av[rt].pb(av[r1][i]);
av[rt].pb(av[r2][i]);
}
return rt;
for(auto [u, v] : av[rt])
cout << u << ' ' << v << endl;
cout << "done " << x[rt] << ' ' << y[rt] << endl;
}
void create_circuit(int m, std::vector<int> a) {
int n = a.size();
if(n == 1){
c.pb(a[0]);
for(int i = 0; i < m; i++)
c.pb(0);
answer(c, x, y);
}
build(n);
c.pb(a[0]);
for(int i = 0; i < m; i++)
c.pb(-1);
a.pb(0);
for(int i = 0; i < n; i++){
if(av[0][i].se)
y[av[0][i].fi] = a[i + 1];
else
x[av[0][i].fi] = a[i + 1];
}
answer(c, x, y);
for(auto u : c)
cout << u << ' ';
cout << endl;
for(int i = 0; i < x.size(); i++)
cout << x[i] << ' ' << y[i] << endl;
}
Compilation message
doll.cpp: In function 'void create_circuit(int, std::vector<int>)':
doll.cpp:77:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
77 | for(int i = 0; i < x.size(); i++)
| ~~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
12 ms |
23764 KB |
DO NOT PRINT ANYTHING TO STANDARD OUTPUT |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
12 ms |
23764 KB |
DO NOT PRINT ANYTHING TO STANDARD OUTPUT |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
12 ms |
23764 KB |
DO NOT PRINT ANYTHING TO STANDARD OUTPUT |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
13 ms |
23764 KB |
DO NOT PRINT ANYTHING TO STANDARD OUTPUT |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
34 ms |
47948 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
34 ms |
47948 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |