#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef pair<double, double> dodo;
#define mp(x, y) make_pair(x, y)
#define pb(x) push_back(x)
#define LIM (100000)
int N;
int tcs[2000];
vi ans1;
vii ans2;
void func(int total, int v1, int v2, int k) {
if (total > 2000) return;
ans1[total] += k;
int val = total + 1;
if (v1 == v2) {
func(total + val-v1, val, v2, 2*k);
} else {
func(total + val-v1, val, v2, k);
func(total + val-v2, v1, val, k);
}
}
void precalc() {
for (int m = 0; m < (1<<23)-1; m++) {
int last1val = 0, last0val = 0;
int total = 0;
int pm = 0;
for (int i = 0; i < 23; i++) {
pm |= (m & (1<<i));
int val = total + 1;
bool type = m & (1<<i);
if (type) {
val -= last1val;
last1val += val;
} else {
val -= last0val;
last0val += val;
}
total += val;
if (total > LIM) break;
if (pm == m) {
if (ans2[total] == mp(-1, -1) || i < ans2[total].second) ans2[total] = mp(pm, i);
}
}
}
}
void solve12() {
ans1.resize(LIM+1);
ans2.resize(LIM+1);
fill(ans2.begin(), ans2.end(), mp(-1, -1));
func(0, 0, 0, 1);
precalc();
//cerr << "DBG" << endl;
for (int i = 0; i < N; i++) {
//cout << tcs[i] << " ";
//cout << -1 << '\n';
cout << ans1[ tcs[i] ] << '\n';
for (int k = 0; k <= ans2[ tcs[i] ].second; k++) {
cout << (bool)( ans2[ tcs[i] ].first & (1<<k) ) << " ";
}
cout << '\n';
}
cerr << '\n';
for (int i = 1; i <= 50; i++) {
cerr << i << " : " << ans1[ i ] << '\n';
}
//cerr << "DBG" << endl;
}
int main(int argc, char **argv) {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> N;
for (int i = 0; i < N; i++) cin >> tcs[i];
if (all_of(tcs, tcs+N, [](int x){return x <= 100000;})) solve12();
else exit(-1);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1002 ms |
1656 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1090 ms |
1656 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
1656 KB |
Execution failed because the return code was nonzero |
2 |
Halted |
0 ms |
0 KB |
- |