Submission #1054161

# Submission time Handle Problem Language Result Execution time Memory
1054161 2024-08-12T07:08:50 Z Gray Radio Towers (IOI22_towers) C++17
14 / 100
705 ms 24280 KB
    #include "towers.h"
    #include <algorithm>
    #include <vector>
    #include <iostream>
    #define ll int
    #define ff first
    #define ss second
    #define ln "\n"
     
    using namespace std;
    struct SegTree{
         #define node vector<ll>
         vector<node> t;
         ll sz, rsz;
         void init(ll N){
              sz=N*4;
              rsz=N;
              t.resize(sz);
         }
         void clear(){
              t.clear();
              sz=rsz=0;
         }
         void merge(node &p, node &l, node &r){
              ll p1=0, p2=0;
              while (p1<(ll)l.size() or p2<(ll)r.size()){
                   if (p2==(ll)r.size() or (p1<(ll)l.size() and l[p1]<r[p2])){
                        p.push_back(l[p1++]);
                   }else{
                        p.push_back(r[p2++]);
                   }
              }
         }
         void build(ll tl, ll tr, ll v, vector<ll> &a){
              if (tl==tr){
                   ll dif=0;
                   if (tl-1>=0 and tl+1<(ll)a.size()){
                        dif=max(dif, min(a[tl]-a[tl-1], a[tl]-a[tl+1]));
                   }
                   t[v].push_back(dif);
              }else{
                   ll tm = (tl+tr)/2;
                   build(tl, tm, v*2, a);
                   build(tm+1, tr, v*2+1, a);
                   merge(t[v], t[v*2], t[v*2+1]);
              }
         }
         void build(vector<ll> &a){
              build(0, rsz-1, 1, a);
         }
         void query(ll tl, ll tr, ll v, ll l, ll r, ll D, ll &wr){
              if (tl==l and tr==r){
                   wr+=(ll)t[v].size()-(lower_bound(t[v].begin(), t[v].end(), D)-t[v].begin());
              }else if (l>r) return;
              else{
                   ll tm = (tl+tr)/2;
                   query(tl, tm, v*2, l, min(r, tm), D, wr);
                   query(tm+1, tr, v*2+1, max(l, tm+1), r, D, wr);
              }
         }
         ll query(ll l, ll r, ll D){
              ll res=0;
              query(0, rsz-1, 1, l, r, D, res);
              return res;
         }
    };
     
    vector<ll> fa;
    SegTree tr;
    ll fn;
    void init(int N, std::vector<int> H) {
         fa=H;
         fn=N;
         tr.clear();
         tr.init(N);
         tr.build(fa);
    }
    // smallt -> 
    // bigt -> 
    int max_towers(int L, int R, int D) {
         return tr.query(L+1, R-1, D)+1;
    }
# Verdict Execution time Memory Grader output
1 Incorrect 279 ms 13912 KB 12th lines differ - on the 1st token, expected: '2', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB 1st lines differ - on the 1st token, expected: '13', found: '11'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB 1st lines differ - on the 1st token, expected: '13', found: '11'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 503 ms 24140 KB Output is correct
2 Correct 639 ms 24276 KB Output is correct
3 Correct 608 ms 24276 KB Output is correct
4 Correct 633 ms 24276 KB Output is correct
5 Correct 647 ms 24276 KB Output is correct
6 Correct 705 ms 24268 KB Output is correct
7 Correct 614 ms 24276 KB Output is correct
8 Correct 580 ms 24268 KB Output is correct
9 Correct 646 ms 24276 KB Output is correct
10 Correct 613 ms 24268 KB Output is correct
11 Correct 658 ms 24272 KB Output is correct
12 Correct 685 ms 24276 KB Output is correct
13 Correct 589 ms 24268 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 1 ms 600 KB Output is correct
16 Correct 1 ms 600 KB Output is correct
17 Correct 34 ms 24268 KB Output is correct
18 Correct 28 ms 24268 KB Output is correct
19 Correct 28 ms 24196 KB Output is correct
20 Correct 25 ms 24272 KB Output is correct
21 Correct 24 ms 24268 KB Output is correct
22 Correct 32 ms 24268 KB Output is correct
23 Correct 27 ms 24280 KB Output is correct
24 Correct 36 ms 24136 KB Output is correct
25 Correct 25 ms 24276 KB Output is correct
26 Correct 27 ms 24272 KB Output is correct
27 Correct 1 ms 600 KB Output is correct
28 Correct 1 ms 600 KB Output is correct
29 Correct 1 ms 600 KB Output is correct
30 Correct 1 ms 600 KB Output is correct
31 Correct 0 ms 600 KB Output is correct
32 Correct 1 ms 596 KB Output is correct
33 Correct 1 ms 600 KB Output is correct
34 Correct 1 ms 600 KB Output is correct
35 Correct 1 ms 600 KB Output is correct
36 Correct 1 ms 600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 191 ms 6228 KB 1st lines differ - on the 1st token, expected: '7197', found: '5748'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB 1st lines differ - on the 1st token, expected: '13', found: '11'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 279 ms 13912 KB 12th lines differ - on the 1st token, expected: '2', found: '1'
2 Halted 0 ms 0 KB -