// Made by TheQuantiX
#include <bits/stdc++.h>
//#pragma GCC optimize("O3,unroll-loops")
//#pragma GCC target("avx2,sse4.2,bmi,bmi2,lzcnt,popcnt")
using namespace std;
using ll = long long;
constexpr ll MAXN = 1e5;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1000000000000000000LL;
ll tt, n, m, k, x, y, a, b, c, d;
vector< vector<int> > devise_strategy(int n) {
vector< vector<int> > ans(1, vector<int>(n + 1));
queue< pair< pair<int, int>, pair< pair<int, int>, pair<int, int> > > > q;
q.push({{0, 0}, {{1, n}, {1, n}}});
while (!q.empty()) {
auto p = q.front();
q.pop();
ll l = p.second.first.first;
ll r = p.second.first.second;
ll lt = p.second.second.first;
ll rt = p.second.second.second;
ll x = p.first.first;
// cout << x << ' ' << l << ' ' << r << endl;
ans[x].resize(n + 1);
ans[x][0] = p.first.second;
for (int i = lt; i <= l; i++) {
if (p.first.second == 0) {
ans[x][i] = -1;
}
else {
ans[x][i] = -2;
}
}
// cout << "DEBUG" << endl;
for (int i = r; i <= rt; i++) {
if (p.first.second == 0) {
ans[x][i] = -2;
}
else {
ans[x][i] = -1;
}
}
l++;
r--;
// cout << "DEBUG" << endl;
if (l > r) {
continue;
}
int mid = (r + l) / 2;
ll y = x;
if (y % 2 == 1) {
y++;
}
if (y + 1 >= ans.size()) {
ans.resize(y + 2);
}
for (int i = l; i <= mid; i++) {
ans[x][i] = y + 1;
}
q.push({{y + 1, 1 - p.first.second}, {{l, mid}, {l - 1, r + 1}}});
// cout << "DEBUG" << endl;
if (l != r) {
if (y + 2 >= ans.size()) {
ans.resize(y + 3);
}
for (int i = mid + 1; i <= r; i++) {
ans[x][i] = y + 2;
}
q.push({{y + 2, 1 - p.first.second}, {{mid + 1, r}, {l - 1, r + 1}}});
}
}
return ans;
}
//void solve() {
// cin >> n;
// auto x = devise_strategy(n);
//// for (auto &i : x) {
//// for (auto j : i) {
//// cout << j << ' ';
//// }
//// cout << '\n';
//// }
//// cout << x.size() << '\n';
//}
//
//int main() {
// ios_base::sync_with_stdio(0);
// cin.tie(0);
// cout.tie(0);
// cout << fixed;
// cout << setprecision(10);
// tt = 1;
//// cin >> tt;
// while (tt --> 0) {
// solve();
// }
//}
Compilation message
prison.cpp: In function 'std::vector<std::vector<int> > devise_strategy(int)':
prison.cpp:59:19: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
59 | if (y + 1 >= ans.size()) {
| ~~~~~~^~~~~~~~~~~~~
prison.cpp:68:23: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
68 | if (y + 2 >= ans.size()) {
| ~~~~~~^~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
244 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
2 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
6 ms |
596 KB |
Output is correct |
5 |
Partially correct |
9 ms |
852 KB |
Output is partially correct |
6 |
Partially correct |
14 ms |
980 KB |
Output is partially correct |
7 |
Partially correct |
11 ms |
964 KB |
Output is partially correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
2 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
4 ms |
468 KB |
Output is correct |
12 |
Correct |
9 ms |
852 KB |
Output is correct |