結果
問題 |
No.640 76本のトロンボーン
|
ユーザー |
![]() |
提出日時 | 2025-05-01 14:28:56 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 1,956 bytes |
コンパイル時間 | 3,114 ms |
コンパイル使用メモリ | 278,472 KB |
実行使用メモリ | 6,272 KB |
最終ジャッジ日時 | 2025-05-01 14:29:01 |
合計ジャッジ時間 | 3,947 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 15 |
ソースコード
#include <bits/stdc++.h> using namespace std; using i64 = long long; int main() { cin.tie(nullptr)->sync_with_stdio(false); auto solve = [&]() { int n; cin >> n; vector<string> s(n); for (int i = 0; i < n; i++) { cin >> s[i]; } auto transpose = [&]() { for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { swap(s[i][j], s[j][i]); } } }; int ans = 0; if ([&]() { for (int i = 0; i < n; i++) { if (s[i][0] == '#' || s[i][n - 1] == '#' || s[0][i] == '#' || s[n - 1][i] == '#') { return false; } } return true; }()) { ans = max(ans, 4); } auto work = [&]() { int res = 0; for (int j = 0; j < n; j++) { int x = 0; for (int i = 0; i < n; i++) { if (s[i][j] == '.') { x++; } else { x = 0; } if (x == n - 1) { res++; break; } } } return res; }; for (int rep = 0; rep < 2; rep++) { ans = max(ans, work()); for (int i = 0; i < n; i++) { for (int j : {0, 1}) { if (s[i].substr(j, n - 1) == string(n - 1, '.')) { fill(s[i].begin() + j, s[i].begin() + j + n - 1, '#'); ans = max(ans, work() + 1); fill(s[i].begin() + j, s[i].begin() + j + n - 1, '.'); } } } transpose(); } cout << ans << '\n'; }; solve(); return 0; }