Submission #100571

# Submission time Handle Problem Language Result Execution time Memory
100571 2019-03-12T10:42:20 Z MohamedAhmed0 Bob (COCI14_bob) C++14
12 / 120
267 ms 18012 KB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n , m ;
    scanf("%d %d" , &n , &m) ;
    int arr[n][m] , last[n][m];
    for(int i = 0 ; i < n ; ++i)
    {
        for(int j = 0 ; j < m ; ++j)
            scanf("%d" , &arr[i][j]) ;
    }
    for(int i = 0 ; i < n ; ++i)
    {
        last[i][m-1] = m-1 ;
        for(int j = m-2 ; j >= 0 ; --j)
        {
            if(arr[i][j] == arr[i][j+1])
                last[i][j] = last[i][j+1] ;
            else
                last[i][j] = j ;
        }
    }
    long long ans = 0ll ;
    for(int i = 0 ; i < n ; ++i)
    {
        for(int j = 0 ; j < m ; ++j)
        {
            for(int k = i ; k >= 0 ; --k)
            {
                if(arr[i][j] != arr[k][j])
                    break;
                ans += min(last[i][j]-j+1ll , last[k][j]-j+1ll) * 1ll ;
            }
        }
    }
    return cout<<ans<<"\n" , 0 ;
}

Compilation message

bob.cpp: In function 'int main()':
bob.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     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("%d" , &arr[i][j]) ;
             ~~~~~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 356 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 45 ms 2816 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 73 ms 3200 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 39 ms 3412 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 65 ms 3492 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 162 ms 15020 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 185 ms 18012 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 267 ms 17968 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 259 ms 17784 KB Output isn't correct
2 Halted 0 ms 0 KB -