結果
| 問題 | No.3805 Crossword Key Maker |
| ユーザー |
|
| 提出日時 | 2026-11-14 15:45:52 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 2 ms / 2,000 ms |
| + 648µs | |
| コード長 | 1,753 bytes |
| 記録 | |
| コンパイル時間 | 2,777 ms |
| コンパイル使用メモリ | 358,664 KB |
| 実行使用メモリ | 9,868 KB |
| 最終ジャッジ日時 | 2026-11-14 15:45:58 |
| 合計ジャッジ時間 | 5,803 ms |
|
ジャッジサーバーID (参考情報) |
judge5_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 43 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
ios::sync_with_stdio(false);
cin.tie(0);
int h, w;
cin >> h >> w;
vector<string> A(h), B(w, string(h, '?'));
vector<pair<int,int>> ans;
vector<vector<int>> C(h, vector<int>(w, 0));
for(int y = 0; y < h; y++){
auto &&ss = A[y];
cin >> ss;
for(int i = 0; i < w; ){
int p = i;
while(i < w && ss[i] == ss[p]) i++;
if(ss[p] == '#') continue;
if(i - p >= 2) ans.emplace_back(y, p), C[y][p] |= 1;
}
}
for(int y = 0; y < h; y++){
for(int x = 0; x < w; x++){
B[x][y] = A[y][x];
}
}
for(int x = 0; x < w; x++){
auto &&ss = B[x];
for(int i = 0; i < h; ){
int p = i;
while(i < h && ss[i] == ss[p]) i++;
if(ss[p] == '#') continue;
if(i - p >= 2) ans.emplace_back(p, x), C[p][x] |= 2;
}
}
sort(ans.begin(), ans.end());
ans.erase(unique(ans.begin(), ans.end()), ans.end());
for(auto &&s : A){
for(int x = 0; x < w; x++){
if(s[x] == '.') s[x] = 'a';
}
}
auto ext_x = [&](int y, int x) -> string {
if(~C[y][x] & 1) return "-";
string res;
while(x < w && A[y][x] != '#') res += A[y][x++];
return res;
};
auto ext_y = [&](int y, int x) -> string {
if(~C[y][x] & 2) return "-";
string res;
while(y < h && A[y][x] != '#') res += A[y++][x];
return res;
};
cout << ans.size() << '\n';
for(auto [y, x] : ans){
cout << ext_x(y, x) << ' ' << ext_y(y, x) << '\n';
}
}