結果

問題 No.3339 Tree on Checkerboard
コンテスト
ユーザー こめだわら
提出日時 2026-01-08 23:14:21
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
結果
WA  
実行時間 -
コード長 3,350 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,959 ms
コンパイル使用メモリ 348,656 KB
実行使用メモリ 8,320 KB
最終ジャッジ日時 2026-01-08 23:14:40
合計ジャッジ時間 18,077 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 49 WA * 1 RE * 48
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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>
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<string> S(N,string(N,'.'));
    if (N%2==0){
        if (N==8){
            cout<<-1<<'\n';
        }
        if (N>=12){
            assert(false);
            cout<<-1<<'\n';
            return;
        }
        vector<string> sub(N/2,string(N,'#'));
        if (N==2){
            sub={"."};
        }
        if (N==4){
            sub={"#.",".."};
        }
        if (N==6){
            sub={"#..",".#.","..."};
        }
        if (N==10){
            sub={"#....",".#.#.","..#..",".#.#.","....."};
        }
        rep(i,N){
            rep(j,N){
                if ((i+j)%2==0)S[i][j]='#';
            }
        }
        rep(i,N/2){
            rep(j,N/2){
                S[2*i][2*j]=sub[i][j];
            }
        }
        rep(i,N){
            cout<<S[i]<<'\n';
        }
        return;
    }
    ll M=(N+1)/2;
    vector<string> sub(M,string(M,'.'));
    if (M%3==0 or M%3==2){
        rep(i,M){
            rep(j,M){
                if ((i+j)%2==1){
                    sub[i][j]='#';
                }
            }
        }
        rep(i,M){
            if (i%3==1){
                rep(j,M){
                    sub[i][j]='.';
                }
            }
            if (i%6==4){
                sub[i][0]='#';
            }
            else{
                sub[i][0]='.';
            }
        }
    }
    else{
        rep(i,M){
            rep(j,M){
                if ((i+1+j)%2==1){
                    sub[i][j]='#';
                }
            }
        }
        rep(i,M){
            if ((i+1)%3==1){
                rep(j,M){
                    sub[i][j]='.';
                }
            }
            if ((i+1)%6==4){
                sub[i][0]='#';
            }
            else{
                sub[i][0]='.';
            }
        }
    }
    rep(i,N){
        rep(j,N){
            if ((i+j)%2==0){
                S[i][j]='#';
            }
        }
    }
    rep(i,M){
        rep(j,M){
            S[2*i][2*j]=sub[i][j];
        }
    }
    // rep(i,M){
    //     cout<<sub[i]<<'\n';
    // }
    rep(i,N){
        cout<<S[i]<<'\n';
    }
    return;
}


int main() {
    cin.tie(0)->sync_with_stdio(0);
    ll T=1;
    while (T--){
        solve();
    }
    return 0;
}
0