제출 #723096

#제출 시각아이디문제언어결과실행 시간메모리
723096GrandTiger1729Rectangles (IOI19_rect)C++17
13 / 100
151 ms49540 KiB
#include "rect.h" #include <bits/stdc++.h> using namespace std; long long count_rectangles(std::vector<std::vector<int>> g){ int n = g.size(), m = g[0].size(); int ans = 0; vector<pair<int, int>> res; for (int i = 1; i < n; i++){ for (auto &[l, r]: res){ bool flag = 0; for (int j = l; j <= r; j++) flag |= g[i][j] == 0; ans += !flag; } vector<pair<int, int>> tmp; for (auto &[l, r]: res){ if (g[i][l - 1] == 1 && g[i][r + 1] == 1){ bool flag = 0; for (int j = l; j <= r; j++) flag |= g[i][j] == 1; if (!flag) tmp.emplace_back(l, r); } } for (int j = 0; j < m - 1; ){ if (g[i][j] == 1){ j++; int l = j, r = j; while (r < m && g[i][r] == 0) r++; if (r == m) break; r--; if (i == 1 && l == 2 && r == 2) cerr << "OK" << endl; bool flag = 0; for (; j <= r; j++) flag |= g[i - 1][j] == 0; if (!flag && l <= r) tmp.emplace_back(l, r); }else j++; } swap(res, tmp); // cerr << i << endl; // for (auto &[l, r]: res) // cerr << l << ' ' << r << endl; } 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...