#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<set<int>> &tree, int c, int &S, set<int> can){
vis[head] = true;
set<int> ncan;
for(int i : can){
if(tree[head].find(i) != tree[head].end()){
ncan.insert(i);
}
}
for(int i : ncan){
if(!vis[i]){
dfs(i, vis, tree, c + 1, S, ncan);
}
}
S = max(S, c);
}
int max_towers(int L, int R, int D){
vector<set<int>> tree(N);
for(int i = L; i <= R; i ++){
int maxi = H[i];
for(int j = i; j <= R; j ++){
if(H[i] + D <= maxi && H[j] + D <= maxi){
tree[i].insert(j);
tree[j].insert(i);
}
maxi = max(maxi, H[j]);
}
}
int S = 0;
for(int i = L; i <= R; i ++){
vector<bool> vis(N);
set<int> can;
for(int j : tree[i]){
can.insert(j);
}
dfs(i, vis, tree, 1, S, can);
}
return S;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
4059 ms |
3596 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
336 KB |
Output is correct |
2 |
Execution timed out |
4073 ms |
52356 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
336 KB |
Output is correct |
2 |
Execution timed out |
4073 ms |
52356 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
4103 ms |
1052200 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
4094 ms |
957744 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
336 KB |
Output is correct |
2 |
Execution timed out |
4073 ms |
52356 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
4059 ms |
3596 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |