이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
int r, s, a, b, c[501][501];
long long pref[501][501];
inline long long get_sm(int x1, int x2, int y1, int y2){
return pref[x2][y2] - pref[x1][y2] - pref[x2][y1] + pref[x1][y1];
}
signed main(){
ios_base::sync_with_stdio(0), cin.tie(0);
cin >> r >> s >> a >> b;
for(register int i = 1; i <= r; ++i){
for(register int j = 1; j <= s; ++j){
cin >> c[i][j];
pref[i][j] = pref[i-1][j] + pref[i][j-1] - pref[i-1][j-1] + c[i][j];
}
}
long long ans = 1e17 + 7;
for(register int x1 = 1; x1 <= r; ++x1){
for(register int y1 = 1; y1 <= s; ++y1){
for(register int x2 = x1; x2 <= r; ++x2){
for(register int y2 = y1; y2 <= s; ++y2){
long long cur = get_sm(x1, x2, y1, y2);
ans = min(ans, 0ll + abs(cur - a) + abs(cur - b));
//if(cur > max(a, b)) break;
}
}
}
}
cout << ans << '\n';
}
컴파일 시 표준 에러 (stderr) 메시지
Main.cpp: In function 'int main()':
Main.cpp:15:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
15 | for(register int i = 1; i <= r; ++i){
| ^
Main.cpp:16:20: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
16 | for(register int j = 1; j <= s; ++j){
| ^
Main.cpp:24:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
24 | for(register int x1 = 1; x1 <= r; ++x1){
| ^~
Main.cpp:26:20: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
26 | for(register int y1 = 1; y1 <= s; ++y1){
| ^~
Main.cpp:28:21: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
28 | for(register int x2 = x1; x2 <= r; ++x2){
| ^~
Main.cpp:30:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
30 | for(register int y2 = y1; y2 <= s; ++y2){
| ^~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |