답안 #1079276

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1079276 2024-08-28T12:34:47 Z ProtonDecay314 송신탑 (IOI22_towers) C++17
14 / 100
700 ms 1964 KB
// AM + DG
#include "towers.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<vpi> vvpi;
typedef vector<vpll> vvpll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef short int si;
typedef vector<si> vsi;
typedef vector<vsi> vvsi;
#define IOS ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define L(varll, mn, mx) for(ll varll = (mn); varll < (mx); varll++)
#define LR(varll, mx, mn) for(ll varll = (mx); varll > (mn); varll--)
#define LI(vari, mn, mx) for(int vari = (mn); vari < (mx); vari++)
#define LIR(vari, mx, mn) for(int vari = (mx); vari > (mn); vari--)
#define INPV(varvec) for(auto& varveci : (varvec)) cin >> varveci
#define fi first
#define se second
#define pb push_back
#define INF(type) numeric_limits<type>::max()
#define NINF(type) numeric_limits<type>::min()
#define TCASES int t; cin >> t; while(t--)

int n;
vi h;
vi inds;

void init(int N, vi H) {
    n = N;
    h = H;

    for(int i = 0; i < n; i++) {
        if((i == 0 || h[i] < h[i - 1]) && (i == n - 1 || h[i] < h[i + 1])) {
            inds.pb(i);
        }
    }
}

int max_towers(int L, int R, int D) {
    int inds_sz = inds.size();

    int l1 = -1, r1 = inds_sz;

    while(r1 - l1 > 1) {
        int m = (l1 + r1) >> 1;

        if(inds[m] >= L) r1 = m;
        else l1 = m;
    }

    int l2 = -1, r2 = inds_sz;

    while(r2 - l2 > 1) {
        int m = (l2 + r2) >> 1;

        if(inds[m] <= R) l2 = m;
        else r2 = m;
    }

    int ans = 0;

    if(r1 > l2) {
        // None found, just do the special case

        if(L == R) ans = 0;
        else {
            if(h[L] <= h[L + 1]) ans++;
            if(h[R] <= h[R - 1]) ans++;
        }
    } else {
        // We got some !!
        int lv = inds[r1], rv = inds[l2];
        ans += l2 - r1 + 1;

        if(L != lv && h[L] <= h[L + 1]) ans++;
        if(R != rv && h[R] <= h[R - 1]) ans++;
    }

    return max(ans, 1);
}

/*
The last frontier
*/
# 결과 실행 시간 메모리 Grader output
1 Incorrect 254 ms 1112 KB 2nd lines differ - on the 1st token, expected: '1', found: '2'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '13', found: '16'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '13', found: '16'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 522 ms 1880 KB Output is correct
2 Correct 649 ms 1880 KB Output is correct
3 Correct 640 ms 1880 KB Output is correct
4 Correct 626 ms 1880 KB Output is correct
5 Correct 682 ms 1880 KB Output is correct
6 Correct 700 ms 1880 KB Output is correct
7 Correct 672 ms 1880 KB Output is correct
8 Correct 635 ms 1368 KB Output is correct
9 Correct 620 ms 1368 KB Output is correct
10 Correct 628 ms 1368 KB Output is correct
11 Correct 619 ms 1368 KB Output is correct
12 Correct 655 ms 1368 KB Output is correct
13 Correct 623 ms 1368 KB Output is correct
14 Correct 0 ms 340 KB Output is correct
15 Correct 1 ms 344 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 9 ms 1880 KB Output is correct
18 Correct 9 ms 1880 KB Output is correct
19 Correct 9 ms 1964 KB Output is correct
20 Correct 8 ms 1364 KB Output is correct
21 Correct 10 ms 1624 KB Output is correct
22 Correct 16 ms 1880 KB Output is correct
23 Correct 12 ms 1872 KB Output is correct
24 Correct 9 ms 1880 KB Output is correct
25 Correct 8 ms 1368 KB Output is correct
26 Correct 8 ms 1368 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 0 ms 344 KB Output is correct
29 Correct 1 ms 344 KB Output is correct
30 Correct 0 ms 408 KB Output is correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 1 ms 344 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 1 ms 344 KB Output is correct
35 Correct 0 ms 344 KB Output is correct
36 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 182 ms 600 KB 1st lines differ - on the 1st token, expected: '7197', found: '8004'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '13', found: '16'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 254 ms 1112 KB 2nd lines differ - on the 1st token, expected: '1', found: '2'
2 Halted 0 ms 0 KB -