Submission #799263

# Submission time Handle Problem Language Result Execution time Memory
799263 2023-07-31T11:26:59 Z elotelo966 Zemljište (COCI22_zemljiste) C++17
30 / 70
2000 ms 4184 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define OYY 1000000005
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mid (start+end)/2
#define mod 1000000007
int pre[505][505],dizi[505][505];

int32_t main(){
    faster
    int n,m,a,b;
    cin>>n>>m>>a>>b;
    int maxi=abs(a-b);
    if(maxi&1)maxi++;
    maxi/=2;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin>>dizi[i][j];
            pre[i][j]=pre[i-1][j]+pre[i][j-1]-pre[i-1][j-1]+dizi[i][j];
        }
    }
    //////////////DEBUG
    /*for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cout<<pre[i][j]<<" ";
        }
        cout<<endl;
    }*/
    int mini=OYY;
    bool stop=true;
    for(int i=1;i<=n && stop;i++){
        for(int j=i;j<=n && stop;j++){
            for(int o=1;o<=m && stop;o++){
                for(int p=o;p<=m && stop;p++){
                    int deg=pre[j][p]-pre[i-1][p]-pre[j][o-1]+pre[i-1][o-1];
                    //cout<<pre[j][p]<<" "<<pre[i-1][p]<<" "<<pre[j][o-1]<<" "<<pre[i-1][o-1]<<endl;
                    deg=abs(deg-a)+abs(deg-b);
                    mini=min(mini,deg);
                    if(maxi==mini)stop=false;
                }
            }
        }
    }
    cout<<mini<<'\n';
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 588 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 588 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 15 ms 852 KB Output is correct
11 Correct 53 ms 1108 KB Output is correct
12 Correct 61 ms 1108 KB Output is correct
13 Correct 55 ms 1108 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 60 ms 1104 KB Output is correct
16 Correct 53 ms 1108 KB Output is correct
17 Correct 56 ms 1108 KB Output is correct
18 Correct 53 ms 1108 KB Output is correct
19 Correct 59 ms 1108 KB Output is correct
20 Correct 56 ms 1108 KB Output is correct
21 Correct 54 ms 1108 KB Output is correct
22 Correct 51 ms 1108 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 468 KB Output is correct
3 Correct 1 ms 588 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 15 ms 852 KB Output is correct
11 Correct 53 ms 1108 KB Output is correct
12 Correct 61 ms 1108 KB Output is correct
13 Correct 55 ms 1108 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 60 ms 1104 KB Output is correct
16 Correct 53 ms 1108 KB Output is correct
17 Correct 56 ms 1108 KB Output is correct
18 Correct 53 ms 1108 KB Output is correct
19 Correct 59 ms 1108 KB Output is correct
20 Correct 56 ms 1108 KB Output is correct
21 Correct 54 ms 1108 KB Output is correct
22 Correct 51 ms 1108 KB Output is correct
23 Execution timed out 2058 ms 4184 KB Time limit exceeded
24 Halted 0 ms 0 KB -