Submission #1271677

#TimeUsernameProblemLanguageResultExecution timeMemory
1271677pxsitMosaic (IOI24_mosaic)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

vector<long long> mosaic(vector<int> x, vector<int> y,vector<int> T, vector<int> B,vector<int> L, vector<int> R){
    int n = x.size(), q = T.size();
    vector<long long> ans(q,0);
    if(n == 1){
        for(int i=0;i<q;i++) ans[i] = x[0];
        return ans;
    }
    for(int i = 1;i<n;i++) pref[i] = pref[i-1] + x[i];
    for(int qrs=0;qrs<q;qrs++){
        int t = T[qrs],b = B[qrs],l = L[qrs],r = R[qrs];
        if(l == 0){
            ans = pref[r];
        }else{
            ans = pref[r] - pref[l - 1];
        }
    }
    return ans;
}

Compilation message (stderr)

mosaic.cpp: In function 'std::vector<long long int> mosaic(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
mosaic.cpp:12:28: error: 'pref' was not declared in this scope
   12 |     for(int i = 1;i<n;i++) pref[i] = pref[i-1] + x[i];
      |                            ^~~~
mosaic.cpp:16:19: error: 'pref' was not declared in this scope
   16 |             ans = pref[r];
      |                   ^~~~
mosaic.cpp:18:19: error: 'pref' was not declared in this scope
   18 |             ans = pref[r] - pref[l - 1];
      |                   ^~~~