답안 #1046766

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1046766 2024-08-06T22:08:20 Z Trent 송신탑 (IOI22_towers) C++17
11 / 100
4000 ms 5092 KB
#include "towers.h"
#include "bits/stdc++.h";
using namespace std;
#define forR(i, x) for(int i = 0; i < (x); ++i)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vi;
typedef vector<vi> vvi;
struct pii{int a, b;};

const int MN = 1e5 + 10;
int h[MN], n;
void init(int N, std::vector<int> H) {
  n = N;
  forR(i, N) h[i] = H[i];
}

int l[MN], r[MN], cmax[MN];
struct event{int ti, i, ty;}; // 0: L, 1: i
int bit[MN];
void upd(int i, int to) {
  bit[i] = max(bit[i], to);
}
int qu(int i) {
  int ret = bit[i];
  for(; i >= 0; --i) ret = max(ret, bit[i]);
  return ret;
}
int max_towers(int L, int R, int D) {
  REP(i, L, R+1) {
    int j;
    for(j = i; j >= L && h[j] < h[i] + D; --j);
    l[i] = j;
    for(j = i; j <= R && h[j] < h[i] + D; ++j);
    r[i] = j;
  }
  vector<event> evs;
  REP(i, L, R+1) {
    evs.push_back({l[i], i, 0});
    evs.push_back({i, i, 1});
  }
  sort(all(evs), [](event& a, event& b){return a.ti < b.ti || a.ti == b.ti && a.ty == 0 && b.ty != 0;});
  for(auto [ti, i, ty] : evs) {
    if(ty == 0) {
      cmax[i] = qu(i) + 1;
    } else {
      upd(r[i] + 1, cmax[i]);
    }
  }
  return qu(MN - 1);
}

Compilation message

towers.cpp:2:25: warning: extra tokens at end of #include directive
    2 | #include "bits/stdc++.h";
      |                         ^
towers.cpp: In lambda function:
towers.cpp:45:89: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   45 |   sort(all(evs), [](event& a, event& b){return a.ti < b.ti || a.ti == b.ti && a.ty == 0 && b.ty != 0;});
      |                                                               ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4014 ms 4048 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 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 528 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 2 ms 344 KB Output is correct
21 Correct 2 ms 344 KB Output is correct
22 Correct 2 ms 344 KB Output is correct
23 Correct 2 ms 344 KB Output is correct
24 Correct 3 ms 344 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 3 ms 344 KB Output is correct
27 Correct 2 ms 344 KB Output is correct
28 Correct 3 ms 344 KB Output is correct
29 Correct 3 ms 344 KB Output is correct
30 Correct 3 ms 588 KB Output is correct
31 Correct 3 ms 480 KB Output is correct
32 Correct 3 ms 344 KB Output is correct
33 Correct 3 ms 344 KB Output is correct
34 Correct 3 ms 344 KB Output is correct
35 Correct 2 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 528 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 2 ms 344 KB Output is correct
21 Correct 2 ms 344 KB Output is correct
22 Correct 2 ms 344 KB Output is correct
23 Correct 2 ms 344 KB Output is correct
24 Correct 3 ms 344 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 3 ms 344 KB Output is correct
27 Correct 2 ms 344 KB Output is correct
28 Correct 3 ms 344 KB Output is correct
29 Correct 3 ms 344 KB Output is correct
30 Correct 3 ms 588 KB Output is correct
31 Correct 3 ms 480 KB Output is correct
32 Correct 3 ms 344 KB Output is correct
33 Correct 3 ms 344 KB Output is correct
34 Correct 3 ms 344 KB Output is correct
35 Correct 2 ms 344 KB Output is correct
36 Correct 150 ms 1880 KB Output is correct
37 Correct 1786 ms 3148 KB Output is correct
38 Correct 560 ms 1992 KB Output is correct
39 Correct 937 ms 2552 KB Output is correct
40 Correct 159 ms 2000 KB Output is correct
41 Execution timed out 4042 ms 5092 KB Time limit exceeded
42 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4021 ms 4860 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4054 ms 2328 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 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 528 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 2 ms 344 KB Output is correct
21 Correct 2 ms 344 KB Output is correct
22 Correct 2 ms 344 KB Output is correct
23 Correct 2 ms 344 KB Output is correct
24 Correct 3 ms 344 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 3 ms 344 KB Output is correct
27 Correct 2 ms 344 KB Output is correct
28 Correct 3 ms 344 KB Output is correct
29 Correct 3 ms 344 KB Output is correct
30 Correct 3 ms 588 KB Output is correct
31 Correct 3 ms 480 KB Output is correct
32 Correct 3 ms 344 KB Output is correct
33 Correct 3 ms 344 KB Output is correct
34 Correct 3 ms 344 KB Output is correct
35 Correct 2 ms 344 KB Output is correct
36 Correct 150 ms 1880 KB Output is correct
37 Correct 1786 ms 3148 KB Output is correct
38 Correct 560 ms 1992 KB Output is correct
39 Correct 937 ms 2552 KB Output is correct
40 Correct 159 ms 2000 KB Output is correct
41 Execution timed out 4042 ms 5092 KB Time limit exceeded
42 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4014 ms 4048 KB Time limit exceeded
2 Halted 0 ms 0 KB -