Submission #709009

# Submission time Handle Problem Language Result Execution time Memory
709009 2023-03-13T03:59:09 Z vjudge1 Domino (COCI15_domino) C++17
30 / 160
864 ms 47440 KB
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
using namespace std;
int main() {
    ll n,k;
    cin>>n>>k;
    ll a[n][n];
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>a[i][j];
        }
    }
    while(k--){
        ll mx=-1,x,y,z=1;
        for(int i=0;i<n-1;i++){
            for(int j=0;j<n;j++){
                if(a[i][j]+a[i+1][j]>mx){
                    mx=a[i][j]+a[i+1][j];
                    x=i;
                    y=j;
                }
            }
        }
        for(int i=0;i<n;i++){
            for(int j=0;j<n-1;j++){
                if(a[i][j]+a[i][j+1]>mx){
                    mx=a[i][j]+a[i][j+1];
                    x=i;
                    y=j;
                    z=2;
                }
            }
        }
        a[x][y]=0;
        if(z==1)a[x+1][y]=0;
        else a[x][y+1]=0;
    }
    ll s=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            s+=a[i][j];
        }
    }
    cout<<s;
    return 0;
}

Compilation message

domino.cpp: In function 'int main()':
domino.cpp:39:16: warning: 'y' may be used uninitialized in this function [-Wmaybe-uninitialized]
   39 |         a[x][y]=0;
      |         ~~~~~~~^~
domino.cpp:39:16: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
# Verdict Execution time Memory Grader output
1 Correct 47 ms 3184 KB Output is correct
2 Correct 54 ms 3128 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 810 ms 46824 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 473 ms 26332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 191 ms 11828 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 813 ms 46808 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 830 ms 46684 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 842 ms 46704 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 213 ms 11808 KB Output is correct
2 Correct 220 ms 11932 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 864 ms 46816 KB Output is correct
2 Correct 839 ms 47440 KB Output is correct