Submission #160620

#TimeUsernameProblemLanguageResultExecution timeMemory
160620eggag32Rectangles (IOI19_rect)C++17
0 / 100
167 ms150248 KiB
#define __AVX__ 1 #define __AVX2__ 1 #define __SSE__ 1 #define __SSE2__ 1 #define __SSE2_MATH__ 1 #define __SSE3__ 1 #define __SSE4_1__ 1 #define __SSE4_2__ 1 #define __SSE_MATH__ 1 #define __SSSE3__ 1 #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math") #pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native") #include <bits/stdc++.h> #include <x86intrin.h> #include "rect.h" //#include "grader.cpp" using namespace std; typedef long long ll; typedef long double ld; typedef vector<int> vi; typedef pair<int, int> pi; #define debug(x) cerr << #x << ": " << x << endl; #define debug2(x, y) debug(x) debug(y); #define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++) #define rep(i, a) for(int i = 0; i < (int)(a); i++) #define all(v) v.begin(), v.end() #define mp make_pair #define pb push_back #define lb lower_bound #define ub upper_bound #define fi first #define se second #define sq(x) ((x) * (x)) template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); } ll count_rectangles(vector<vi> a){ int n = a.size(); int m = a[0].size(); bool ver[n + 5][m + 5][m + 5]; bool hor[m + 5][n + 5][n + 5]; memset(ver, 0, sizeof(ver)); memset(hor, 0, sizeof(hor)); repn(i, 1, n - 1){ int hor1[m + 5][m + 5]; memset(hor1, 0, sizeof(hor1)); repn(j, 1, m - 1) repn(k, j, m - 1){ if(j == k){ hor1[j][k] = a[i][j]; if(hor1[j][k] < a[i][j - 1] && hor1[j][k] < a[i][k + 1]) hor[i][j][k] = 1; } else{ hor1[j][k] = max(hor1[j][k - 1], a[i][k]); if(hor1[j][k] < a[i][j - 1] && hor1[j][k] < a[i][k + 1]) hor[i][j][k] = 1; } } } repn(j, 1, m - 1){ int ver1[n + 5][n + 5]; memset(ver1, 0, sizeof(ver1)); repn(i, 1, n - 1) repn(k, i, n - 1){ if(i == k){ ver1[i][k] = a[i][j]; if(ver1[i][k] < a[i - 1][j] && ver1[i][k] < a[k + 1][j]) ver[j][i][k] = 1; } else{ ver1[i][k] = max(ver1[i][k - 1], a[k][j]); if(ver1[i][k] < a[i - 1][j] && ver1[i][k] < a[k + 1][j]) ver[j][i][k] = 1; } } } ll ans = 0; repn(i, 1, n - 1) repn(j, 1, m - 1) repn(k, i, n - 1) repn(l, j, m - 1){ int f = 1; repn(x, i, k + 1){ if(!hor[x][j][l] || !hor[x][j][l]){ f = 0; break; } } if(!f) continue; repn(x, j, l + 1){ if(!ver[x][i][k] || !ver[x][i][k]){ f = 0; break; } } if(!f) continue; ans++; } return ans; } /* Things to look out for: - Integer overflows - Array bounds - Special cases Be careful! */
#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...