Submission #230159

# Submission time Handle Problem Language Result Execution time Memory
230159 2020-05-08T18:48:01 Z EmmanuelAC Bob (COCI14_bob) C++14
72 / 120
75 ms 4392 KB
#include<bits/stdc++.h>
using namespace std;

#define ll long long

ll mat[501][501], h[501][501];

int main(){
    int n, m;   scanf("%d %d",&n, &m);

    for(int i=1; i<=n; i++){
        for(int j=1; j<=m; j++){
            scanf("%lld", &mat[i][j]);

            if(mat[i][j] == mat[i-1][j])
                h[i][j] = h[i-1][j] +1;
            else
                h[i][j] = 1;
        }
    }
    
    ll sol = 0;
    for(int i=1; i<=n; i++){

        for(int j=1; j<=m; j++){
            ll curr_min = h[i][j];
            for(int k=0; k<j; k++){
                if(mat[i][j -k] == mat[i][j]){
                    curr_min = min(h[i][j -k], curr_min);
                    sol += curr_min;
                }
                else{
                    break;
                }
            }

        }

    }

    printf("%lld\n", sol);

}

Compilation message

bob.cpp: In function 'int main()':
bob.cpp:9:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     int n, m;   scanf("%d %d",&n, &m);
                 ~~~~~^~~~~~~~~~~~~~~~
bob.cpp:13:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%lld", &mat[i][j]);
             ~~~~~^~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 35 ms 4344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 51 ms 4344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 44 ms 4344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 44 ms 4344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 65 ms 4392 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 74 ms 4344 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 75 ms 4344 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 74 ms 4348 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -