結果

問題 No.3733 My First Grid
コンテスト
ユーザー mono
提出日時 2026-09-19 17:17:23
言語 C++23(gcc16)
(gcc 16.1.0 + boost 1.92.0 + ACL)
コンパイル:
g++-16 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 2,147 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,402 ms
コンパイル使用メモリ 387,180 KB
実行使用メモリ 10,028 KB
最終ジャッジ日時 2026-09-19 17:17:32
合計ジャッジ時間 6,386 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 55 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#pragma GCC optimize ("O3,inline,omit-frame-pointer,no-asynchronous-unwind-tables,fast-math")
#include <bits/stdc++.h>
#include <unordered_map>
#include <stdlib.h>
using namespace std;
#define rep(i, a, n) for(ll i = a; i < n; i++)
#define rrep(i, a, n) for(ll i = a; i >= n; i--)
#define inr(l, x, r) (l <= x && x < r)
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(x) (x).begin(), (x).end()
//constexpr ll MOD = 1000000007;
constexpr ll MOD = 998244353;
constexpr int IINF = 1001001001;
constexpr ll INF = 1LL<<60;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll h, w, k; cin >> h >> w >> k;
    if(k == 0){
        rep(i,0,h){
            rep(j,0,w) cout << '.';
            cout << endl;
        }
        return 0;
    }
    if(h == 1){
        if(k == 1){
            string ans(w,'.');
            ans[0] = '#';
            cout << ans << endl;
        }else{
            cout << -1 << endl;
        }
        return 0;
    }
    if(w == 1){
        if(k == 1){
            string ans(w,'.');
            ans[0] = '#';
            for(auto x: ans) cout << x << endl;
        }else{
            cout << -1 << endl;
        }
        return 0;
    }
    if(k == 1){
        cout << -1 << endl;
        return 0;
    }
    if(k <= w){
        vector<string> ans(h,string(w,'.'));
        rep(i,0,k-1) ans[0][i] = '#';
        rep(i,0,h){
            cout << ans[i] << endl;
        }
        return 0;
    }
    if(k > h*w-w-h+2){
        cout << -1 << endl;
        return 0;
    }

    vector<string> ans(h,string(w,'.'));
    rep(i,0,w) ans[0][i] = '#';
    ll now = w;
    rep(j,2,w)rep(i,1,h-1){
        if(j%2) continue;
        if(now > k-(j == w-1 ? 1 : 2)) continue;
        ans[i][j] = '#';
        now += (j == w-1 ? 1 : 2);
    }
    rep(i,1,h-1){
        if(now == k) continue;
        ans[i][0] = '#';
        now++;
    }
    rep(i,0,h){
        cout << ans[i] << endl;
    }
    // assert(now == k);
    return 0;
}
0