結果
| 問題 | No.3730 Jagged Minesweeper |
| コンテスト | |
| ユーザー |
Rice_tawara459
|
| 提出日時 | 2026-09-19 14:50:26 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 697 ms / 2,500 ms |
| + 621µs | |
| コード長 | 2,831 bytes |
| 記録 | |
| コンパイル時間 | 2,293 ms |
| コンパイル使用メモリ | 350,944 KB |
| 実行使用メモリ | 93,864 KB |
| 最終ジャッジ日時 | 2026-09-19 14:50:50 |
| 合計ジャッジ時間 | 21,663 ms |
|
ジャッジサーバーID (参考情報) |
judge5_0 / judge4_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 43 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define all(a) (a).begin(),(a).end()
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
template<class T> T div_floor(T a, T b) { return a / b - ((a ^ b) < 0 && a % b); }
template<class T> T div_ceil(T a, T b) { return a / b + ((a ^ b) > 0 && a % b); }
template <typename T, typename U> inline bool chmin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template <typename T, typename U> inline bool chmax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T,typename U>
ostream &operator<<(ostream &os,const pair<T,U> &p){
return os<<p.first<<' '<<p.second;
}
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &a){
if (a.empty()) return os;
os << a.front();
for (auto e : a | views::drop(1)){
os << ' ' << e;
}
return os;
}
void dump(auto ...vs){
((cout << vs << ' '), ...) << endl;
}
void solve() {
ll N;
cin>>N;
vector A(N,vector<ll> (N,0));
rep(i,N){
string s;
cin>>s;
rep(j,N){
A[i][j]=s[j]-'0';
}
}
vector<string> B(N,string(N,'.'));
auto check=[&](ll i,ll j){
ll cnt=0;
for (ll k=i-1;k<=i+1;k++){
for (ll l=j-1;l<=j+1;l++){
if (k<0 or k>=N or l<0 or l>=N)continue;
if (B[k][l]=='o'){
cnt++;
}
}
}
if (B[i][j]=='o'){
if (A[i][j]<cnt)return false;
}
else{
if (A[i][j]>cnt)return false;
}
return true;
};
stack<pair<ll,ll>> st;
rep(i,N){
rep(j,N){
if (!check(i,j)){
st.emplace(i,j);
// dump(i,j);
}
}
}
auto flip=[](char &c){
if (c=='o')c='.';
else c='o';
return;
};
while (st.size()>0){
auto [ci,cj]=st.top();st.pop();
if (check(ci,cj))continue;
// dump(B);
flip(B[ci][cj]);
// dump(B);
assert(check(ci,cj));
for (ll k=ci-1;k<=ci+1;k++){
for (ll l=cj-1;l<=cj+1;l++){
if (k<0 or k>=N or l<0 or l>=N)continue;
if (k==ci and l==cj)continue;
if (!check(k,l)){
st.emplace(k,l);
}
}
}
}
rep(i,N){
cout<<B[i]<<'\n';
}
return;
}
int main() {
cin.tie(0)->sync_with_stdio(0);
ll T=1;
while (T--){
solve();
}
return 0;
}
Rice_tawara459