Submission #297460

#TimeUsernameProblemLanguageResultExecution timeMemory
297460infinite_iqRectangles (IOI19_rect)C++14
0 / 100
7 ms10624 KiB
#include <bits/stdc++.h> using namespace std ; #define mid (l+r)/2 #define pb push_back #define C continue #define lb lower_bound typedef long long ll ; typedef vector < int > vi ; #include "rect.h" int n , m ; int a [2509][2509] ; int pre [2509][2509][2] ; int Sum ( int id , int l , int r , int t ) { return pre [id][r][t] - ( l ? pre [id][l-1][t] : 0 ) ; } long long count_rectangles ( vector <vi> A ) { n = A .size () ; m = A [0] .size () ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { a [i][j] = A [i][j] ; } } for ( int i = 0 ; i < n ; i ++ ) { int crnt = 0 ; for ( int j = 0 ; j < m ; j ++ ) { crnt += a [i][j] ; pre [i][j][0] = crnt ; } } for ( int j = 0 ; j < m ; j ++ ) { int crnt = 0 ; for ( int i = 0 ; i < n ; i ++ ) { crnt += a [i][j] ; pre [j][i][1] = crnt ; } } ll ans = 0 ; for ( int i = 1 ; i < n - 1 ; i ++ ) { for ( int k = 1 ; k < m - 1 ; k ++ ) { int l = i , r = n - 1 ; while ( r - l > 1 ) { if ( Sum ( k , i , mid , 1 ) == 0 ) l = mid ; else r = mid ; } int j = l ; l = k , r = m - 1 ; while ( r - l > 1 ) { if ( Sum ( i , k , mid , 0 ) == 0 ) l = mid ; else r = mid ; } if ( Sum ( k - 1 , i , j , 1 ) != j - i + 1 ) C ; if ( Sum ( l + 1 , i , j , 1 ) != j - i + 1 ) C ; if ( Sum ( i - 1 , k , l , 0 ) != l - k + 1 ) C ; if ( Sum ( j + 1 , k , l , 0 ) != l - k + 1 ) C ; ans ++ ; } } return ans ; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...