Submission #629316

# Submission time Handle Problem Language Result Execution time Memory
629316 2022-08-14T11:08:16 Z peti1234 Radio Towers (IOI22_towers) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

using namespace std;
const int c=100005;
int n, t[c], pos;

void init(int N, vector<int> sz) {
    n=N;
    for (int i=0; i<n; i++) {
        t[i+1]=sz[i];
        if (t[i+1]>t[i]) pos++;
    }
}

void lassu(int l, int r, int d) {
    int ut=t[l]+d, ans=0, id=1;
    for (int i=l; i<=r; i++) {
        if (id==1) {
            ut=max(ut, t[i]);
            if (ut-t[i]>=d) {
                ut=t[i];
                id=0;
                ans++;
            }
        } else {
            ut=min(ut, t[i]);
            if (t[i]-ut>=d) {
                ut=t[i];
                id=1;
            }
        }
    }
    return ans;
}

int max_towers(int l, int r, int d) {
    l++, r++;
    if (l<=pos && pos<=r && max(t[l], t[r])+d<=t[pos]) return 2;
    return 1;
}
/*
int main()
{
    int N;
    vector<int> P;
    cin >> N;
    for (int i=0; i<N; i++) {
        int x;
        cin >> x;
        P.push_back(x);
    }
    init(N, P);
    int q;
    cin >> q;
    while (q--) {
        int l, r, d;
        cin >> l >> r >> d;
        cout << max_towers(l, r, d) << "\n";
    }
    return 0;
}
*/
/*
7
1 2 6 4 5 3 7
3
1 5 1
1 5 2
1 5 3
*/

Compilation message

towers.cpp: In function 'void lassu(int, int, int)':
towers.cpp:33:12: error: return-statement with a value, in function returning 'void' [-fpermissive]
   33 |     return ans;
      |            ^~~