//
#ifndef __SIZEOF_INT128__
#define __SIZEOF_INT128__
#endif
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace chrono;
using namespace __gnu_pbds;
template <typename T> using oset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define rep(i, p, k) for(int i(p); i < (k); ++i)
#define per(i, p, k) for(int i(p); i > (k); --i)
#define sz(x) (int)(x).size()
#define sc static_cast
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef __int128_t lll;
//#define int ll
template <typename T = int> using par = std::pair <T, T>;
#define fi first
#define se second
#define test int _number_of_tests(in()); while(_number_of_tests--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb emplace_back
struct Timer {
string name{""};
time_point<high_resolution_clock> end, start{high_resolution_clock::now()};
duration<float, std::milli> dur;
Timer() = default;
Timer(string nm): name(nm) {}
~Timer() {
end = high_resolution_clock::now(); dur= end - start;
cout << "@" << name << "> " << dur.count() << " ms" << '\n';
}
};
template <typename T = int> inline T in()
{
static T x;
std::cin >> x;
return x;
}
std::string yn(bool b)
{
if(b) return "YES\n";
else return "NO\n";
}
template <typename F, typename S> std::ostream& operator<<(std::ostream& out, const std::pair <F, S>& par);
template <typename T> std::ostream& operator<< (std::ostream& out, const std::vector <T>& wek)
{
for(const auto& i : wek)out << i << ' ';
return out;
}
template <typename F, typename S> std::ostream& operator<<(std::ostream& out, const std::pair <F, S>& par)
{
out << '{'<<par.first<<", "<<par.second<<"}";
return out;
}
#define show(x) cerr << #x << " = " << x << '\n';
#include "doll.h"
void create_circuit(int m, vector <int> a)
{
a.pb(0);
vector <int> c(m+1, -1);
vector <int> x{0}, y{0};
int d(1), p(0);
while(d < sz(a)){
d *= 2;
++p;
}
vector <int> v(d, -1);
int ind(0);
rep(i, 0, d){
int j(0);
rep(k, 0, p)if(i&1<<k)j |= 1<<(p-1-k);
v[j] = (j < (d-sz(a)) ? -1 : a[ind++]);
}
while(d > 2){
d /= 2;
--p;
vector <int> w(d);
rep(i, 0, d){
if(v[2*i] == v[2*i+1])w[i] = v[2*i];
else{
x.pb(v[2*i]);
y.pb(v[2*i+1]);
w[i] = -sz(x);
}
}
// cerr << v << '\n';
v = w;
}
// cerr << v << '\n';
x[0] = v[0];
y[0] = v[1];
// cerr << '{' << c << "} ";
// cerr << '{' << x << "} ";
// cerr << '{' << y << "} ";
// cerr << '\n';
answer(c, x, y);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
31 ms |
4692 KB |
Output is correct |
3 |
Correct |
22 ms |
3928 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
5 ms |
1372 KB |
Output is correct |
6 |
Correct |
29 ms |
5712 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 |
31 ms |
4692 KB |
Output is correct |
3 |
Correct |
22 ms |
3928 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
5 ms |
1372 KB |
Output is correct |
6 |
Correct |
29 ms |
5712 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
41 ms |
6384 KB |
Output is correct |
9 |
Correct |
43 ms |
6780 KB |
Output is correct |
10 |
Correct |
53 ms |
8772 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 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 |
31 ms |
4692 KB |
Output is correct |
3 |
Correct |
22 ms |
3928 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
5 ms |
1372 KB |
Output is correct |
6 |
Correct |
29 ms |
5712 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
41 ms |
6384 KB |
Output is correct |
9 |
Correct |
43 ms |
6780 KB |
Output is correct |
10 |
Correct |
53 ms |
8772 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
53 ms |
8768 KB |
Output is correct |
15 |
Correct |
40 ms |
6020 KB |
Output is correct |
16 |
Correct |
51 ms |
8356 KB |
Output is correct |
17 |
Correct |
0 ms |
344 KB |
Output is correct |
18 |
Correct |
0 ms |
348 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
52 ms |
9024 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 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
420 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
25 ms |
2892 KB |
Output is correct |
3 |
Correct |
25 ms |
2896 KB |
Output is correct |
4 |
Correct |
28 ms |
3400 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
25 ms |
2892 KB |
Output is correct |
3 |
Correct |
25 ms |
2896 KB |
Output is correct |
4 |
Correct |
28 ms |
3400 KB |
Output is correct |
5 |
Correct |
52 ms |
8260 KB |
Output is correct |
6 |
Correct |
50 ms |
8256 KB |
Output is correct |
7 |
Correct |
52 ms |
8252 KB |
Output is correct |
8 |
Correct |
49 ms |
8256 KB |
Output is correct |
9 |
Correct |
34 ms |
4944 KB |
Output is correct |
10 |
Correct |
53 ms |
7492 KB |
Output is correct |
11 |
Correct |
63 ms |
8176 KB |
Output is correct |
12 |
Correct |
38 ms |
5708 KB |
Output is correct |
13 |
Correct |
39 ms |
6008 KB |
Output is correct |
14 |
Correct |
49 ms |
6020 KB |
Output is correct |
15 |
Correct |
40 ms |
6008 KB |
Output is correct |
16 |
Correct |
1 ms |
604 KB |
Output is correct |
17 |
Correct |
30 ms |
6404 KB |
Output is correct |
18 |
Correct |
38 ms |
5720 KB |
Output is correct |
19 |
Correct |
48 ms |
5708 KB |
Output is correct |
20 |
Correct |
50 ms |
8264 KB |
Output is correct |
21 |
Correct |
48 ms |
8156 KB |
Output is correct |
22 |
Correct |
55 ms |
8000 KB |
Output is correct |