Submission #1070333

#TimeUsernameProblemLanguageResultExecution timeMemory
1070333c2zi6Radio Towers (IOI22_towers)C++17
4 / 100
638 ms2260 KiB
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define replr(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define reprl(i, a, b) for (int i = int(a); i >= int(b); --i)
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define mkp(a, b) make_pair(a, b)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VPI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<VPI> VVPI;
typedef pair<ll, ll> PLL;
typedef vector<ll> VL;
typedef vector<PLL> VPL;
typedef vector<VL> VVL;
typedef vector<VVL> VVVL;
typedef vector<VPL> VVPL;
template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;}
template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;}
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T>
using indset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#include "towers.h"

namespace TEST1 {
    bool check(VI h) {
        VI a;
        a.pb(-1);
        for (int x : h) a.pb(x);
        a.pb(-1);

        int cnt = 0;
        replr(i, 1, a.size()-2) if (a[i] > a[i-1] && a[i] > a[i+1]) cnt++;
        return cnt <= 1;
    }
    int mx = -1;
    int mxv = -2e9;
    int n;
    VI h;
    void init(int N, VI H) {
        n = N;
        h = H;
        rep(i, n) if (h[i] > mxv) {
            mx = i;
            mxv = h[i];
        }
    }
    int max_towers(int l, int r, int D) {
        if (l < mx && mx < r) {
            if (max(h[l], h[r]) + D <= mxv) return 2;
            return 1;
        }
        return 1;
    }
}

int test = -1;

void init(int N, VI H) {
    if (TEST1::check(H)) {
        TEST1::init(N, H);
        test = 1;
    }
}

int max_towers(int l, int r, int D) {
    if (test == -1) return -1;
    if (test == 1) return TEST1::max_towers(l, r, D);
    return 1;
}







#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...