Submission #967411

#TimeUsernameProblemLanguageResultExecution timeMemory
967411IsamZemljište (COCI22_zemljiste)C++17
30 / 70
2025 ms5972 KiB
#include<bits/stdc++.h> using namespace std; int r, s, a, b, c[501][501]; long long pref[501][501], ans; 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]; ans += c[i][j]; pref[i][j] = pref[i-1][j] + pref[i][j-1] - pref[i-1][j-1] + c[i][j]; } } for(register int x1 = 0; x1 <= r; ++x1){ for(register int y1 = 0; y1 <= s; ++y1){ for(register int x2 = x1; x2 <= r; ++x2){ for(register int y2 = y1; y2 <= s; ++y2){ if(x1==x2 && y1==y2) continue; long long cur = get_sm(x1, x2, y1, y2); ans = min(ans, abs(cur - a) + abs(cur - b)); if(cur >= max(a, b)) break; } } } } cout << ans << '\n'; }

Compilation message (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:23:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   23 |  for(register int x1 = 0; x1 <= r; ++x1){
      |                   ^~
Main.cpp:25:20: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   25 |   for(register int y1 = 0; y1 <= s; ++y1){
      |                    ^~
Main.cpp:27:21: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   27 |    for(register int x2 = x1; x2 <= r; ++x2){
      |                     ^~
Main.cpp:29:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   29 |     for(register int y2 = y1; y2 <= s; ++y2){
      |                      ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...