Submission #835139

# Submission time Handle Problem Language Result Execution time Memory
835139 2023-08-23T09:01:17 Z gagik_2007 Radio Towers (IOI22_towers) C++17
14 / 100
830 ms 3940 KB
#include "towers.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define ff first
#define ss second

ll ttt;
const ll INF=1e18;
const ll MOD=1e9+7;
const ll N=100007;
ll n,m,k;
vector<int>a;
vector<int>d;
struct Node{
    int sum;
    Node():sum(0){}
    void bld(int vl){
        sum=vl;
    }
    void join(const Node& lft, const Node& rgh){
        sum=lft.sum+rgh.sum;
    }
};
Node t[4*N];

void build(int v, int tl, int tr){
    if(tl==tr){
        t[v].bld(d[tl]);
    }
    else{
        int tm=(tl+tr)/2;
        build(2*v,tl,tm);
        build(2*v+1,tm+1,tr);
        t[v].join(t[2*v],t[2*v+1]);
    }
}

int get_sum(int v, int tl, int tr, int l, int r){
    if(l>r)return 0;
    if(tl==l&&tr==r)return t[v].sum;
    else{
        int tm=(tl+tr)/2;
        return get_sum(2*v,tl,tm,l,min(tm,r))+
            get_sum(2*v+1,tm+1,tr,max(tm+1,l),r);
    }
}

void init(int NN, vector<int> H) {
    n=NN;
    a=H;
    a.insert(a.begin(),MOD);
    a.push_back(MOD);
    for(int i=1;i<=n;i++){
        if(a[i]<a[i+1]&&a[i]<a[i-1])d.push_back(1);
        else d.push_back(0);
    }
    build(1,0,n-1);
}

int max_towers(int L, int R, int D) {
    if(L==R)return 1;
    int res=get_sum(1,0,n-1,L,R);
    if(a[L+1]<a[L+2]&&a[L+1]>a[L])res++;
    if(a[R+1]<a[R]&&a[R+1]>a[R+2])res++;
    return res;
}
# Verdict Execution time Memory Grader output
1 Incorrect 373 ms 3024 KB 2nd lines differ - on the 1st token, expected: '1', found: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1872 KB 1st lines differ - on the 1st token, expected: '13', found: '16'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1872 KB 1st lines differ - on the 1st token, expected: '13', found: '16'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 531 ms 3892 KB Output is correct
2 Correct 713 ms 3888 KB Output is correct
3 Correct 523 ms 3900 KB Output is correct
4 Correct 696 ms 3924 KB Output is correct
5 Correct 616 ms 3912 KB Output is correct
6 Correct 531 ms 3920 KB Output is correct
7 Correct 799 ms 3904 KB Output is correct
8 Correct 632 ms 3888 KB Output is correct
9 Correct 473 ms 3904 KB Output is correct
10 Correct 830 ms 3924 KB Output is correct
11 Correct 689 ms 3900 KB Output is correct
12 Correct 730 ms 3940 KB Output is correct
13 Correct 452 ms 3896 KB Output is correct
14 Correct 1 ms 1744 KB Output is correct
15 Correct 1 ms 1872 KB Output is correct
16 Correct 1 ms 1872 KB Output is correct
17 Correct 11 ms 3896 KB Output is correct
18 Correct 10 ms 3900 KB Output is correct
19 Correct 10 ms 3900 KB Output is correct
20 Correct 11 ms 3928 KB Output is correct
21 Correct 16 ms 3900 KB Output is correct
22 Correct 11 ms 3912 KB Output is correct
23 Correct 10 ms 3924 KB Output is correct
24 Correct 10 ms 3880 KB Output is correct
25 Correct 15 ms 3904 KB Output is correct
26 Correct 10 ms 3900 KB Output is correct
27 Correct 1 ms 1872 KB Output is correct
28 Correct 1 ms 1872 KB Output is correct
29 Correct 1 ms 1872 KB Output is correct
30 Correct 1 ms 1872 KB Output is correct
31 Correct 1 ms 1872 KB Output is correct
32 Correct 1 ms 1872 KB Output is correct
33 Correct 1 ms 1872 KB Output is correct
34 Correct 2 ms 1872 KB Output is correct
35 Correct 1 ms 1872 KB Output is correct
36 Correct 1 ms 1872 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 115 ms 2364 KB 1st lines differ - on the 1st token, expected: '7197', found: '8004'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 1872 KB 1st lines differ - on the 1st token, expected: '13', found: '16'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 373 ms 3024 KB 2nd lines differ - on the 1st token, expected: '1', found: '2'
2 Halted 0 ms 0 KB -