답안 #628216

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
628216 2022-08-13T08:17:28 Z TheQuantiX 송신탑 (IOI22_towers) C++17
4 / 100
1039 ms 2996 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 (q == 1) {
        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 554 ms 1828 KB Output is correct
2 Correct 1026 ms 2956 KB Output is correct
3 Correct 1020 ms 2976 KB Output is correct
4 Correct 963 ms 2960 KB Output is correct
5 Correct 843 ms 2940 KB Output is correct
6 Correct 812 ms 2976 KB Output is correct
7 Correct 1039 ms 2968 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 208 KB 1st lines differ - on the 1st token, expected: '13', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 208 KB 1st lines differ - on the 1st token, expected: '13', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 725 ms 2996 KB 1st lines differ - on the 1st token, expected: '11903', found: '2'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 283 ms 848 KB 1st lines differ - on the 1st token, expected: '7197', found: '2'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 208 KB 1st lines differ - on the 1st token, expected: '13', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 554 ms 1828 KB Output is correct
2 Correct 1026 ms 2956 KB Output is correct
3 Correct 1020 ms 2976 KB Output is correct
4 Correct 963 ms 2960 KB Output is correct
5 Correct 843 ms 2940 KB Output is correct
6 Correct 812 ms 2976 KB Output is correct
7 Correct 1039 ms 2968 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Incorrect 1 ms 208 KB 1st lines differ - on the 1st token, expected: '13', found: '1'
12 Halted 0 ms 0 KB -