Submission #960777

# Submission time Handle Problem Language Result Execution time Memory
960777 2024-04-11T03:34:24 Z Zero_OP Lightning Conductor (POI11_pio) C++14
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>

using namespace std;

int ceil_sqrt(int n){
    int x = sqrt(n);
    while(x * x < n) ++x;
    return x;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n; cin >> n;
    vector<int> h(n);
    vector<vector<int>> st;
    st.push_back(vector<int>(n));
    for(int i = 0; i < n; ++i){
        cin >> h[i];
        st[0][i] = h[i];
    }

    for(int i = 1; (1 << i) <= n; ++i){
        st.push_back(vector<int>(n - (1 << i) + 1));
        for(int j = 0; j + (1 << i) <= n; ++j){
            st[i][j] = max(st[i - 1][j], st[i - 1][j + (1 << (i - 1))]);
        }
    }

    auto max_range = [&](int l, int r){
        int b = 31 - __builtin_clz(r - l  + 1);
        return max(st[b][l], st[b][r - (1 << b) + 1]);
    };

    vector<int> p(n);
    for(int i = 0; i < n; ++i){ 
        if(i != 0){
            int B = ceil_sqrt(i);
            for(int k = 1; k <= B; ++k){
                p[i] = max(p[i], max_range(max(0, i - k * k), i - (k - 1) * (k - 1) + 1) + k - h[i]);
            }
        }

        if(i != n - 1){
            int B = ceil_sqrt(n - 1 - i);
            for(int k = 1; k <= B; ++k){
                p[i] = max(p[i], max_range(i + (k - 1) * (k - 1) + 1, min(n - 1, i + k * k)) + k - h[i]);
            }
        }
    }

    for(int i = 0; i < n; ++i){
        cout << p[i] << '\n';
    }
    
    return 0;
}

Compilation message

pio.cpp:41:2: error: extended character   is not valid in an identifier
   41 |                 p[i] = max(p[i], max_range(max(0, i - k * k), i - (k - 1) * (k - 1) + 1) + k - h[i]);
      |  ^
pio.cpp:41:5: error: extended character   is not valid in an identifier
   41 |                 p[i] = max(p[i], max_range(max(0, i - k * k), i - (k - 1) * (k - 1) + 1) + k - h[i]);
      |    ^
pio.cpp:41:8: error: extended character   is not valid in an identifier
   41 |                 p[i] = max(p[i], max_range(max(0, i - k * k), i - (k - 1) * (k - 1) + 1) + k - h[i]);
      |      ^
pio.cpp:41:11: error: extended character   is not valid in an identifier
   41 |                 p[i] = max(p[i], max_range(max(0, i - k * k), i - (k - 1) * (k - 1) + 1) + k - h[i]);
      |        ^
pio.cpp:41:14: error: extended character   is not valid in an identifier
   41 |                 p[i] = max(p[i], max_range(max(0, i - k * k), i - (k - 1) * (k - 1) + 1) + k - h[i]);
      |          ^
pio.cpp:41:17: error: extended character   is not valid in an identifier
   41 |                 p[i] = max(p[i], max_range(max(0, i - k * k), i - (k - 1) * (k - 1) + 1) + k - h[i]);
      |            ^
pio.cpp:41:20: error: extended character   is not valid in an identifier
   41 |                 p[i] = max(p[i], max_range(max(0, i - k * k), i - (k - 1) * (k - 1) + 1) + k - h[i]);
      |              ^
pio.cpp:41:23: error: extended character   is not valid in an identifier
   41 |                 p[i] = max(p[i], max_range(max(0, i - k * k), i - (k - 1) * (k - 1) + 1) + k - h[i]);
      |                ^
pio.cpp:48:2: error: extended character   is not valid in an identifier
   48 |                 p[i] = max(p[i], max_range(i + (k - 1) * (k - 1) + 1, min(n - 1, i + k * k)) + k - h[i]);
      |  ^
pio.cpp:48:5: error: extended character   is not valid in an identifier
   48 |                 p[i] = max(p[i], max_range(i + (k - 1) * (k - 1) + 1, min(n - 1, i + k * k)) + k - h[i]);
      |    ^
pio.cpp:48:8: error: extended character   is not valid in an identifier
   48 |                 p[i] = max(p[i], max_range(i + (k - 1) * (k - 1) + 1, min(n - 1, i + k * k)) + k - h[i]);
      |      ^
pio.cpp:48:11: error: extended character   is not valid in an identifier
   48 |                 p[i] = max(p[i], max_range(i + (k - 1) * (k - 1) + 1, min(n - 1, i + k * k)) + k - h[i]);
      |        ^
pio.cpp:48:14: error: extended character   is not valid in an identifier
   48 |                 p[i] = max(p[i], max_range(i + (k - 1) * (k - 1) + 1, min(n - 1, i + k * k)) + k - h[i]);
      |          ^
pio.cpp:48:17: error: extended character   is not valid in an identifier
   48 |                 p[i] = max(p[i], max_range(i + (k - 1) * (k - 1) + 1, min(n - 1, i + k * k)) + k - h[i]);
      |            ^
pio.cpp:48:20: error: extended character   is not valid in an identifier
   48 |                 p[i] = max(p[i], max_range(i + (k - 1) * (k - 1) + 1, min(n - 1, i + k * k)) + k - h[i]);
      |              ^
pio.cpp:48:23: error: extended character   is not valid in an identifier
   48 |                 p[i] = max(p[i], max_range(i + (k - 1) * (k - 1) + 1, min(n - 1, i + k * k)) + k - h[i]);
      |                ^
pio.cpp: In function 'int main()':
pio.cpp:41:2: error: '\U000000a0' was not declared in this scope
   41 |                 p[i] = max(p[i], max_range(max(0, i - k * k), i - (k - 1) * (k - 1) + 1) + k - h[i]);
      |  ^
pio.cpp:48:2: error: '\U000000a0' was not declared in this scope
   48 |                 p[i] = max(p[i], max_range(i + (k - 1) * (k - 1) + 1, min(n - 1, i + k * k)) + k - h[i]);
      |  ^