#include "Anna.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
namespace {
}
int Declare() {
return 2000;
}
std::pair<std::vector<int>, std::vector<int> > Anna(long long A) {
int l = 3, a = 0, b = 0, m = 0;
ll cnt = 1;
while(true) {
ll sz = l/3;
if(cnt + (sz + 1) * (sz + 1) * (2 * l - 4 * sz + 1) < A) {
cnt += (sz + 1) * (sz + 1) * (2 * l - 4 * sz + 1);
++l;
}
else break;
}
while(true) {
ll sz = l/3;
if(cnt + (sz + 1) * (2 * l - 4 * sz + 1) < A) {
cnt += (sz + 1) * (2 * l - 4 * sz + 1);
++a;
}
else break;
}
while(true) {
ll sz = l/3;
if(cnt + (2 * l - 4 * sz + 1) < A) {
cnt += 2 * l - 4 * sz + 1;
++b;
}
else break;
}
m = A - cnt;
int sz = l/3;
vector<int> s(l, 0);
vector<int> t(l, 0);
for(int i = 0; i < a; ++i) s[i] = t[sz - 1 - i] = 1;
for(int i = 0; i < b; ++i) s[l - 1 - i] = t[l - sz + i] = 1;
for(int i = 0; i < min(m, l - 2 * sz); ++i) s[sz + i] = 1;
for(int i = 0; i < m - (l - 2 * sz); ++i) t[sz + i] = 1;
// cout << l << ' ' << a << ' ' << b << ' ' << m << endl;
// for(auto v : s) cout << v << ' ';
// cout << endl;
// for(auto v : t) cout << v << ' ';
// cout << endl;
return {s, t};
}
#include "Bruno.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
namespace {
}
long long Bruno(std::vector<int> u) {
int l = u.size();
int a = 0, b = 0, m = 0;
for(int i = 0; i < l/6; ++i) a += u[i], b += u[l - 1 - i];
for(int i = 0; i < l; ++i) m += u[i];
l /= 2;
ll ret = 1;
for(int i = 3; i < l; ++i) {
ll sz = i/3;
ret += (sz + 1) * (sz + 1) * (2 * i - 4 * sz + 1);
}
for(int i = 0; i < a; ++i) {
ll sz = l/3;
ret += (sz + 1) * (2 * l - 4 * sz + 1);
}
for(int i = 0; i < b; ++i) {
ll sz = l/3;
ret += (2 * l - 4 * sz + 1);
}
m -= 2 * (a + b);
ret += m;
return ret;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
784 KB |
Output is correct |
2 |
Incorrect |
10 ms |
1080 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
784 KB |
Output is correct |
2 |
Incorrect |
10 ms |
1080 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
784 KB |
Output is correct |
2 |
Incorrect |
10 ms |
1080 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
784 KB |
Output is correct |
2 |
Incorrect |
10 ms |
1080 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
784 KB |
Output is correct |
2 |
Incorrect |
10 ms |
1080 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
1856 KB |
Wrong Answer [3] |
2 |
Halted |
0 ms |
0 KB |
- |