Submission #103747

# Submission time Handle Problem Language Result Execution time Memory
103747 2019-04-02T12:10:04 Z MohamedAhmed0 Bob (COCI14_bob) C++14
72 / 120
1000 ms 8204 KB
#include <bits/stdc++.h>
 
using namespace std;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

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)
        {
          	long long MIN = 1e9 ;
            for(int k = i ; k >= 0 ; --k)
            {
                if(arr[i][j] != arr[k][j])
                    break;
                MIN = min(MIN , last[k][j] - j + 1ll) ;
                ans += (MIN*1ll) ;
            }
        }
    }
    return printf("%lld" , ans) , 0 ;
}

Compilation message

bob.cpp:5:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization ("O3")
 
bob.cpp:6:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization ("unroll-loops")
 
bob.cpp: In function 'int main()':
bob.cpp:11: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:16: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 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 51 ms 2308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 93 ms 2308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 2308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 62 ms 2312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 222 ms 8204 KB Output is correct
2 Execution timed out 1076 ms 8184 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 218 ms 8168 KB Output is correct
2 Execution timed out 1058 ms 8184 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 321 ms 8160 KB Output is correct
2 Execution timed out 1073 ms 8184 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 350 ms 8136 KB Output is correct
2 Execution timed out 1076 ms 8056 KB Time limit exceeded
3 Halted 0 ms 0 KB -