結果
| 問題 | No.3733 My First Grid |
| コンテスト | |
| ユーザー |
りあん
|
| 提出日時 | 2026-09-19 15:26:43 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 3 ms / 2,000 ms |
| + 715µs | |
| コード長 | 2,563 bytes |
| 記録 | |
| コンパイル時間 | 2,735 ms |
| コンパイル使用メモリ | 356,564 KB |
| 実行使用メモリ | 9,864 KB |
| 最終ジャッジ日時 | 2026-09-19 15:26:53 |
| 合計ジャッジ時間 | 5,870 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge5_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 57 |
ソースコード
// #pragma GCC target("avx2")
#pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
// #include<sys/time.h>
// #include<atcoder/modint>
using namespace std;
// using mint = atcoder::modint998244353;
using P = pair<int, int>;
const int M = 998244353;
const long long LM = 1LL << 60;
vector<string> solve(int h, int w, int k) {
if (k == 0) {
return vector<string>(h, string(w, '.'));
}
if (h == 1 || w == 1) {
if (k == 1) {
vector<string> tmp(h, string(w, '.'));
tmp[0][0] = '#';
return tmp;
}
else {
return {};
}
}
assert(h >= 2 && w >= 2);
if (k == 1) {
return {};
}
assert(h >= 2 && w >= 2 && k >= 2);
if (k < h + w - 1) {
int ci = min(k - 1, h - 1);
int cj = k - ci;
vector<string> tmp(h, string(w, '.'));
for (int i = 0; i < ci; ++i) {
for (int j = 0; j < cj; ++j) {
tmp[i][j] = '#';
}
}
return tmp;
}
for (int sw = 0; sw < 2; ++sw) {
vector<string> b(h, string(w, '.'));
for (int j = 0; j < w; ++j) {
b[0][j] = '#';
}
int rem = k - w;
int si = 1;
int lim = w - 1;
for (; si < h - 1 && rem % 2 == 1; ++si) {
if (rem >= 1) {
lim = w - 2;
b[si][w - 1] = '#';
rem -= 1;
}
}
for (int j = 1; j < lim; j += 2) {
for (int i = 1; i < h - 1; ++i) {
if (rem >= 2) {
b[i][j] = '#';
rem -= 2;
}
}
}
for (; si < h - 1; ++si) {
if (rem >= 1) {
b[si][w - 1] = '#';
rem -= 1;
}
}
if (rem == 0) {
if (sw) {
vector<string> tmp(w, string(h, '.'));
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
tmp[j][i] = b[i][j];
}
}
swap(b, tmp);
}
return b;
}
}
return {};
}
int main() {
cin.tie(0);
ios::sync_with_stdio(0);
int h, w, k;
cin >> h >> w >> k;
auto b = solve(h, w, k);
// cout << b.size() << '\n';
if (b.empty()) {
cout << -1 << '\n';
return 0;
}
for (auto&& i : b) {
cout << i << '\n';
}
return 0;
}
りあん