結果
問題 | No.1056 2D Lamps |
ユーザー |
![]() |
提出日時 | 2019-11-15 23:34:10 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,823 bytes |
コンパイル時間 | 855 ms |
コンパイル使用メモリ | 83,620 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-19 11:01:27 |
合計ジャッジ時間 | 6,000 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 3 |
other | WA * 14 |
ソースコード
#include <algorithm> #include <array> #include <iostream> #include <numeric> #include <vector> auto boolmat(int n, int m) { return std::vector<std::vector<bool>>(n, std::vector<bool>(m, false)); } int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int n, m; std::cin >> n >> m; auto b = boolmat(m, m); const int s = n >= 3 ? (n - 3) * (n - 3) : 0; auto c = boolmat(m, s); for (int i = 0; i < m; ++i) { auto a = boolmat(n, n); for (auto &&v : a) { for (auto &&e : v) { char t; std::cin >> t; e = t != '.'; } } std::array<int, 8> dx = {-2, -2, -1, -1, 0, 0, 1, 1}; std::array<int, 8> dy = {-1, 0, -2, 1, -2, 1, -1, 0}; int j = 0; for (int x = 2; x + 2 <= n; ++x) { for (int y = 2; y + 2 <= n; ++y) { bool t = false; for (int k = 0; k < 8; ++k) { t = t != a[x + dx[k]][y + dy[k]]; } c[i][j] = t; ++j; } } } { std::vector<int> idx(m); std::iota(idx.begin(), idx.end(), 0); for (int j = 0; j < s; ++j) { std::vector<int> f, t; for (const int i : idx) { if (c[i][j]) { t.push_back(i); } else { f.push_back(i); } } std::copy(f.cbegin(), f.cend(), idx.begin()); std::copy(t.cbegin(), t.cend(), idx.begin() + f.size()); } std::vector<int> list; for (int k = 0; k < m; ++k) { const int i = idx[k]; if (k != 0 && c[idx[k - 1]] != c[i]) { list.clear(); } for (const int j : list) { b[i][j] = true; } list.push_back(i); } } for (int i = 0; i < m; ++i) { for (int j = 0; j < m; ++j) { if (i < j) { std::cout << (b[i][j] || b[j][i] ? '1' : '0'); } } std::cout << '\n'; } }