답안 #1035511

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1035511 2024-07-26T11:39:55 Z aymanrs 송신탑 (IOI22_towers) C++17
14 / 100
4000 ms 15444 KB
#include "towers.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> pr, h;
const int K = 17;
vector<pair<int, int>> sp[K];
inline int msb(int x){
    return 31-__builtin_clz(x);
}
int que(int l, int r){
  int d = msb(r-l+1);
  return max(sp[d][l], sp[d][r-(1<<d)+1]).second;
}
void init(int N, std::vector<int> H) {
  h = H;
  pr.resize(N);
  pr[0]=0;
  for(int i = 0;i < K;i++) sp[i].resize(N);
  for(int i = 0;i < N;i++){
    sp[0][i] = {H[i], i};
  }
  for(int k = 1;k < K;k++){
    for(int i = 0;i+(1<<k)<=N;i++){
      sp[k][i] = max(sp[k-1][i], sp[k-1][i+(1<<k-1)]);
    }
  }
  for(int i = 1;i < N-1;i++){
    pr[i]=pr[i-1];
    if(H[i] < H[i-1] && H[i] < H[i+1]) pr[i]++;
  }
}
int de;
int ans(int l, int r, int atm){
  if(l==r){
    if(h[l]<=atm) return 1;
    return 0;
  }
  int m = que(l, r);
  if(l==m) return ans(l+1, r, atm);
  if(m==r) return ans(l, r-1, atm);
  return max(ans(l, m-1, h[m]-de)+ans(m+1, r, h[m]-de), (h[l] <= atm ? 1 : 0));
}
int max_towers(int L, int R, int D) {
  de = D;
  if(L+1>=R) return 1;
  if(D==1) return pr[R-1]-pr[L]+(h[L] < h[L+1])+(h[R]<h[R-1]);
  return ans(L, R, INT_MAX);
}

Compilation message

towers.cpp: In function 'void init(int, std::vector<int>)':
towers.cpp:24:49: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   24 |       sp[k][i] = max(sp[k-1][i], sp[k-1][i+(1<<k-1)]);
      |                                                ~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 3378 ms 9304 KB Output is correct
2 Execution timed out 4090 ms 15164 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Incorrect 1 ms 600 KB 1st lines differ - on the 1st token, expected: '91', found: '53'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Incorrect 1 ms 600 KB 1st lines differ - on the 1st token, expected: '91', found: '53'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 444 ms 15192 KB Output is correct
2 Correct 560 ms 15164 KB Output is correct
3 Correct 614 ms 15192 KB Output is correct
4 Correct 579 ms 15192 KB Output is correct
5 Correct 625 ms 15192 KB Output is correct
6 Correct 650 ms 15192 KB Output is correct
7 Correct 606 ms 15192 KB Output is correct
8 Correct 639 ms 15444 KB Output is correct
9 Correct 571 ms 15216 KB Output is correct
10 Correct 593 ms 15192 KB Output is correct
11 Correct 557 ms 15192 KB Output is correct
12 Correct 624 ms 15192 KB Output is correct
13 Correct 568 ms 15192 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 1 ms 600 KB Output is correct
16 Correct 1 ms 600 KB Output is correct
17 Correct 15 ms 15192 KB Output is correct
18 Correct 15 ms 15312 KB Output is correct
19 Correct 15 ms 15192 KB Output is correct
20 Correct 16 ms 15192 KB Output is correct
21 Correct 14 ms 15192 KB Output is correct
22 Correct 22 ms 15192 KB Output is correct
23 Correct 16 ms 15192 KB Output is correct
24 Correct 16 ms 15192 KB Output is correct
25 Correct 19 ms 15172 KB Output is correct
26 Correct 18 ms 15192 KB Output is correct
27 Correct 1 ms 600 KB Output is correct
28 Correct 0 ms 600 KB Output is correct
29 Correct 0 ms 600 KB Output is correct
30 Correct 0 ms 600 KB Output is correct
31 Correct 1 ms 600 KB Output is correct
32 Correct 1 ms 600 KB Output is correct
33 Correct 0 ms 600 KB Output is correct
34 Correct 0 ms 600 KB Output is correct
35 Correct 1 ms 600 KB Output is correct
36 Correct 1 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4088 ms 3928 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Incorrect 1 ms 600 KB 1st lines differ - on the 1st token, expected: '91', found: '53'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3378 ms 9304 KB Output is correct
2 Execution timed out 4090 ms 15164 KB Time limit exceeded
3 Halted 0 ms 0 KB -