제출 #1271676

#제출 시각아이디문제언어결과실행 시간메모리
1271676pxsitMosaic (IOI24_mosaic)C++20
컴파일 에러
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 i=1;i<n;i++){ for(int j=1;j<n;j++){ if(grid[i-1][j] == 0 && grid[i][j-1] == 0) grid[i][j] = 1; else grid[i][j] = 0; } } 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; }

컴파일 시 표준 에러 (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:15:16: error: 'grid' was not declared in this scope
   15 |             if(grid[i-1][j] == 0 && grid[i][j-1] == 0) grid[i][j] = 1;
      |                ^~~~
mosaic.cpp:22:19: error: 'pref' was not declared in this scope
   22 |             ans = pref[r];
      |                   ^~~~
mosaic.cpp:24:19: error: 'pref' was not declared in this scope
   24 |             ans = pref[r] - pref[l - 1];
      |                   ^~~~