제출 #499187

#제출 시각아이디문제언어결과실행 시간메모리
499187dxz05Rectangles (IOI19_rect)C++14
25 / 100
5061 ms25908 KiB
#pragma GCC optimize("Ofast,O2,O3") #pragma GCC target("avx,avx2") #include "rect.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; #define MP make_pair long long count_rectangles(vector<vector<int>> A) { const int N = A.size(), M = A[0].size(); vector<pair<int, pair<int, int>>> hor; vector<pair<int, pair<int, int>>> ver; for (int i = 0; i < N; i++){ for (int j1 = 0; j1 < M - 2; j1++){ int mx = A[i][j1 + 1]; for (int j2 = j1 + 2; j2 < M; j2++){ if (mx < min(A[i][j1], A[i][j2])){ hor.emplace_back(i, MP(j1, j2)); } mx = max(mx, A[i][j2]); } } } for (int j = 0; j < M; j++) { for (int i1 = 0; i1 < N - 2; i1++) { int mx = A[i1 + 1][j]; for (int i2 = i1 + 2; i2 < N; i2++) { if (mx < min(A[i1][j], A[i2][j])){ ver.emplace_back(j, MP(i1, i2)); } mx = max(mx, A[i2][j]); } } } assert((int)max(hor.size(), ver.size()) <= 4 * N * M); map<vector<int>, int> mp; for (auto x : hor){ int i = x.first, j1 = x.second.first, j2 = x.second.second; int ind = upper_bound(ver.begin(), ver.end(), MP(j1, MP(N, N))) - ver.begin(); for (; ind < ver.size(); ind++){ auto y = ver[ind]; int j = y.first, i1 = y.second.first, i2 = y.second.second; if (i1 < i && i < i2 && j1 < j && j < j2){ mp[{i1, j1, i2, j2}]++; } if (j >= j2) break; } } ll ans = 0; for (auto now : mp){ vector<int> v = now.first; if ((v[2] - v[0] - 1) * (v[3] - v[1] - 1) == now.second){ ans++; } } return ans; }

컴파일 시 표준 에러 (stderr) 메시지

rect.cpp: In function 'long long int count_rectangles(std::vector<std::vector<int> >)':
rect.cpp:49:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |         for (; ind < ver.size(); ind++){
      |                ~~~~^~~~~~~~~~~~
#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...