#include "towers.h"
#include <cassert>
#include <cstdio>
#include <bits/stdc++.h>
using namespace std;
vector<int> H;
int N;
void init(int n, vector<int> h){
H = h;
N = n;
}
void dfs(int head, vector<bool> &vis, vector<bitset<2000>> &tree, int c, int &S, bitset<2000> can){
vis[head] = true;
can &= tree[head];
for(int i = 0; i < N; i ++){
if(!vis[i] && can[i]){
dfs(i, vis, tree, c + 1, S, can);
}
}
S = max(S, c);
}
int max_towers(int L, int R, int D){
vector<bitset<2000>> tree(N);
for(int i = L; i <= R; i ++){
int maxi = H[i];
tree[i][i] = 1;
for(int j = i; j <= R; j ++){
if(H[i] + D <= maxi && H[j] + D <= maxi){
tree[i][j] = 1;
tree[j][i] = 1;
}
maxi = max(maxi, H[j]);
}
}
int S = 0;
for(int i = L; i <= R; i ++){
vector<bool> vis(N);
bitset<2000> can = tree[i];
dfs(i, vis, tree, 1, S, can);
}
return S;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1959 ms |
33348 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Incorrect |
1932 ms |
848 KB |
1st lines differ - on the 1st token, expected: '292', found: '236' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Incorrect |
1932 ms |
848 KB |
1st lines differ - on the 1st token, expected: '292', found: '236' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4046 ms |
27484 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
507 ms |
13080 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Incorrect |
1932 ms |
848 KB |
1st lines differ - on the 1st token, expected: '292', found: '236' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1959 ms |
33348 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |