답안 #628218

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
628218 2022-08-13T08:19:05 Z TheQuantiX 송신탑 (IOI22_towers) C++17
15 / 100
1047 ms 3028 KB
// 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;

int tt, n, q, m, k, x, y, a, b, c, d;
vector<int> v;
vector<int> tr;

void build(ll x, ll l, ll r) {
    if (l == r) {
        tr[x] = v[l];
        return;
    }
    ll mid = (l + r) / 2;
    build(2 * x + 1, l, mid);
    build(2 * x + 2, mid + 1, r);
    tr[x] = max(tr[2 * x + 1], tr[2 * x + 2]);
}

ll query(ll x, ll l, ll r, ll lt, ll rt) {
    if (rt < l || r < lt) {
        return -INF;
    }
    if (rt < lt) {
        return -INF;
    }
    if (l <= lt && rt <= r) {
        return tr[x];
    }
    ll mid = (lt + rt) / 2;
    return max(query(2 * x + 1, l, r, lt, mid), query(2 * x + 2, l, r, mid + 1, rt));
}

void init(int n1, vector<int> h) {
    n = n1;
    v = h;
    tr.resize(h.size() * 4);
    build(0, 0, n - 1);
}

int max_towers(int l, int r, int d) {
    if (n <= 2000) {
        vector<ll> dp(n, 1);
        for (int i = l; i <= r; i++) {
            for (int j = i + 2; j <= r; j++) {
                ll mx = query(0, i, j, 0, n - 1);
                if (mx - v[i] >= d && mx - v[j] >= d) {
                    dp[j] = max(dp[j], dp[i] + 1);
                }
            }
        }
    //    if (*max_element(dp.begin(), dp.end()) == 1) {
    //        return 0;
    //    }
        return *max_element(dp.begin(), dp.end());
    }
    else {
        ll mx = query(0, l, r, 0, n - 1);
        if (mx - v[l] >= d && mx - v[r] >= d) {
            return 2;
        }
        return 1;
    }
}

//void solve() {
//    cin >> n >> q;
//    vector<int> v(n);
//    for (int i = 0; i < n; i++) {
//        cin >> v[i];
//    }
//    init(n, v);
//    for (int i = 0; i < q; i++) {
//        cin >> a >> b >> c;
//        cout << max_towers(a, b, c) << endl;
//    }
//}
//
//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();
//    }
//}
# 결과 실행 시간 메모리 Grader output
1 Correct 433 ms 1872 KB Output is correct
2 Correct 829 ms 3016 KB Output is correct
3 Correct 840 ms 3028 KB Output is correct
4 Correct 1047 ms 2972 KB Output is correct
5 Correct 904 ms 2980 KB Output is correct
6 Correct 708 ms 2976 KB Output is correct
7 Correct 735 ms 2980 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 51 ms 360 KB Output is correct
10 Correct 28 ms 368 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 80 ms 344 KB Output is correct
3 Correct 62 ms 352 KB Output is correct
4 Correct 35 ms 336 KB Output is correct
5 Correct 56 ms 348 KB Output is correct
6 Correct 10 ms 356 KB Output is correct
7 Correct 45 ms 336 KB Output is correct
8 Correct 4 ms 336 KB Output is correct
9 Correct 16 ms 336 KB Output is correct
10 Correct 3 ms 336 KB Output is correct
11 Correct 11 ms 336 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
13 Correct 46 ms 336 KB Output is correct
14 Correct 27 ms 336 KB Output is correct
15 Correct 4 ms 336 KB Output is correct
16 Correct 140 ms 352 KB Output is correct
17 Correct 24 ms 352 KB Output is correct
18 Correct 10 ms 300 KB Output is correct
19 Correct 29 ms 360 KB Output is correct
20 Correct 260 ms 344 KB Output is correct
21 Correct 271 ms 348 KB Output is correct
22 Correct 266 ms 344 KB Output is correct
23 Correct 259 ms 340 KB Output is correct
24 Correct 271 ms 340 KB Output is correct
25 Correct 47 ms 304 KB Output is correct
26 Correct 265 ms 356 KB Output is correct
27 Correct 264 ms 336 KB Output is correct
28 Correct 265 ms 348 KB Output is correct
29 Correct 271 ms 348 KB Output is correct
30 Correct 280 ms 344 KB Output is correct
31 Correct 270 ms 344 KB Output is correct
32 Correct 270 ms 344 KB Output is correct
33 Correct 270 ms 344 KB Output is correct
34 Correct 268 ms 348 KB Output is correct
35 Correct 263 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 80 ms 344 KB Output is correct
3 Correct 62 ms 352 KB Output is correct
4 Correct 35 ms 336 KB Output is correct
5 Correct 56 ms 348 KB Output is correct
6 Correct 10 ms 356 KB Output is correct
7 Correct 45 ms 336 KB Output is correct
8 Correct 4 ms 336 KB Output is correct
9 Correct 16 ms 336 KB Output is correct
10 Correct 3 ms 336 KB Output is correct
11 Correct 11 ms 336 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
13 Correct 46 ms 336 KB Output is correct
14 Correct 27 ms 336 KB Output is correct
15 Correct 4 ms 336 KB Output is correct
16 Correct 140 ms 352 KB Output is correct
17 Correct 24 ms 352 KB Output is correct
18 Correct 10 ms 300 KB Output is correct
19 Correct 29 ms 360 KB Output is correct
20 Correct 260 ms 344 KB Output is correct
21 Correct 271 ms 348 KB Output is correct
22 Correct 266 ms 344 KB Output is correct
23 Correct 259 ms 340 KB Output is correct
24 Correct 271 ms 340 KB Output is correct
25 Correct 47 ms 304 KB Output is correct
26 Correct 265 ms 356 KB Output is correct
27 Correct 264 ms 336 KB Output is correct
28 Correct 265 ms 348 KB Output is correct
29 Correct 271 ms 348 KB Output is correct
30 Correct 280 ms 344 KB Output is correct
31 Correct 270 ms 344 KB Output is correct
32 Correct 270 ms 344 KB Output is correct
33 Correct 270 ms 344 KB Output is correct
34 Correct 268 ms 348 KB Output is correct
35 Correct 263 ms 384 KB Output is correct
36 Incorrect 13 ms 2076 KB 1st lines differ - on the 1st token, expected: '5765', found: '2'
37 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 580 ms 2976 KB 1st lines differ - on the 1st token, expected: '11903', found: '2'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 333 ms 848 KB 1st lines differ - on the 1st token, expected: '7197', found: '2'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 80 ms 344 KB Output is correct
3 Correct 62 ms 352 KB Output is correct
4 Correct 35 ms 336 KB Output is correct
5 Correct 56 ms 348 KB Output is correct
6 Correct 10 ms 356 KB Output is correct
7 Correct 45 ms 336 KB Output is correct
8 Correct 4 ms 336 KB Output is correct
9 Correct 16 ms 336 KB Output is correct
10 Correct 3 ms 336 KB Output is correct
11 Correct 11 ms 336 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
13 Correct 46 ms 336 KB Output is correct
14 Correct 27 ms 336 KB Output is correct
15 Correct 4 ms 336 KB Output is correct
16 Correct 140 ms 352 KB Output is correct
17 Correct 24 ms 352 KB Output is correct
18 Correct 10 ms 300 KB Output is correct
19 Correct 29 ms 360 KB Output is correct
20 Correct 260 ms 344 KB Output is correct
21 Correct 271 ms 348 KB Output is correct
22 Correct 266 ms 344 KB Output is correct
23 Correct 259 ms 340 KB Output is correct
24 Correct 271 ms 340 KB Output is correct
25 Correct 47 ms 304 KB Output is correct
26 Correct 265 ms 356 KB Output is correct
27 Correct 264 ms 336 KB Output is correct
28 Correct 265 ms 348 KB Output is correct
29 Correct 271 ms 348 KB Output is correct
30 Correct 280 ms 344 KB Output is correct
31 Correct 270 ms 344 KB Output is correct
32 Correct 270 ms 344 KB Output is correct
33 Correct 270 ms 344 KB Output is correct
34 Correct 268 ms 348 KB Output is correct
35 Correct 263 ms 384 KB Output is correct
36 Incorrect 13 ms 2076 KB 1st lines differ - on the 1st token, expected: '5765', found: '2'
37 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 433 ms 1872 KB Output is correct
2 Correct 829 ms 3016 KB Output is correct
3 Correct 840 ms 3028 KB Output is correct
4 Correct 1047 ms 2972 KB Output is correct
5 Correct 904 ms 2980 KB Output is correct
6 Correct 708 ms 2976 KB Output is correct
7 Correct 735 ms 2980 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 51 ms 360 KB Output is correct
10 Correct 28 ms 368 KB Output is correct
11 Correct 1 ms 208 KB Output is correct
12 Correct 80 ms 344 KB Output is correct
13 Correct 62 ms 352 KB Output is correct
14 Correct 35 ms 336 KB Output is correct
15 Correct 56 ms 348 KB Output is correct
16 Correct 10 ms 356 KB Output is correct
17 Correct 45 ms 336 KB Output is correct
18 Correct 4 ms 336 KB Output is correct
19 Correct 16 ms 336 KB Output is correct
20 Correct 3 ms 336 KB Output is correct
21 Correct 11 ms 336 KB Output is correct
22 Correct 0 ms 208 KB Output is correct
23 Correct 46 ms 336 KB Output is correct
24 Correct 27 ms 336 KB Output is correct
25 Correct 4 ms 336 KB Output is correct
26 Correct 140 ms 352 KB Output is correct
27 Correct 24 ms 352 KB Output is correct
28 Correct 10 ms 300 KB Output is correct
29 Correct 29 ms 360 KB Output is correct
30 Correct 260 ms 344 KB Output is correct
31 Correct 271 ms 348 KB Output is correct
32 Correct 266 ms 344 KB Output is correct
33 Correct 259 ms 340 KB Output is correct
34 Correct 271 ms 340 KB Output is correct
35 Correct 47 ms 304 KB Output is correct
36 Correct 265 ms 356 KB Output is correct
37 Correct 264 ms 336 KB Output is correct
38 Correct 265 ms 348 KB Output is correct
39 Correct 271 ms 348 KB Output is correct
40 Correct 280 ms 344 KB Output is correct
41 Correct 270 ms 344 KB Output is correct
42 Correct 270 ms 344 KB Output is correct
43 Correct 270 ms 344 KB Output is correct
44 Correct 268 ms 348 KB Output is correct
45 Correct 263 ms 384 KB Output is correct
46 Incorrect 13 ms 2076 KB 1st lines differ - on the 1st token, expected: '5765', found: '2'
47 Halted 0 ms 0 KB -