結果
| 問題 | No.3733 My First Grid |
| コンテスト | |
| ユーザー |
競プロするわりとねこ
|
| 提出日時 | 2026-09-19 17:56:26 |
| 言語 | C++23(gcc16) (gcc 16.1.0 + boost 1.92.0 + ACL) |
| 結果 |
WA
不安定
|
| 実行時間 | - |
| コード長 | 2,991 bytes |
| 記録 | |
| コンパイル時間 | 3,735 ms |
| コンパイル使用メモリ | 365,116 KB |
| 実行使用メモリ | 10,044 KB |
| 最終ジャッジ日時 | 2026-09-19 17:56:54 |
| 合計ジャッジ時間 | 5,543 ms |
|
ジャッジサーバーID (参考情報) |
judge5_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 WA * 29 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
#define ll long long
#define GET_REP(_1, _2, _3, _4,NAME, ...) NAME
#define rep1(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, m, n) for (int i = (n); i < (m); ++i)
#define rep3(i, m, n, o) for (int i = (n); i < (m); i+=o)
#define rep(...) GET_REP(__VA_ARGS__, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(i,n) for (int i = (n); i > 0; i--)
#define nall(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fi first
#define se second
#define getvec(a,n,s) \
vector<s> a(n);\
for (auto& i:a) cin >>i;
#define int long long
#define vi vector<int>
#define vpii vector<pair<int,int>>
#define vs vector<string>
#define vvi vector<vector<int>>
#define vvs vector<vector<string>>
template <typename T>
auto vec(size_t n, T val) {
return std::vector<T>(n, val);
}
template <typename... Sizes>
auto vec(size_t n, Sizes... sizes) {
return std::vector<decltype(vec(sizes...))>(n, vec(sizes...));
}
random_device rd;
mt19937 gen(rd());
//uniform_int_distribution<int> dist();
signed main() {
int h, w, k;
cin >> h >> w >> k;
if(k == 1) {
cout << -1 << endl;
return 0;
}
vpii move = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
vs s(h), t(h);
rep(i, h) {
s[i] = "";
rep(j, w){
s[i] += '.';
}
//cout << s[i] << endl;
}
t = s;
pair<int, int> now = {0, 0};
int bod = 0, mode = 0;
while(true) {
//cout << now.first << " " << now.second << endl;
s[now.first][now.second] = '#';
if((now.first == 0 && now.second == w - 1) || (now.first == h - 1 && now.second == 0) || (now.first == h - 1 && now.second == w - 1)) bod = bod;
else if(now.first == 0 && now.second == 0) bod += 2;
else if(now.first == 0 || now.first == h - 1 || now.second == 0 || now.second == w - 1) {
//kabenotoki
bod += 1;
}
else bod += 2;
if(bod >= k) {
if(bod > k) s[0][0] = '.';
break;
}
bool ok = true;
pair<int,int> next = {now.first + move[mode % 4].first, now.second + move[mode % 4].second};
if(next.first < 0 || next.first > h - 1 || next.second < 0 || next.second > w - 1) ok = false;
if(ok == true && t[next.first][next.second] == 'x') ok = false;
if(ok == false) {
next = now;
mode++;
next = {now.first + move[mode % 4].first, now.second + move[mode % 4].second};
}
rep(i, 4) {
pair<int, int> ng;
ng.first = now.first + move[i].first;
ng.second = now.second + move[i].second;
if(ng.first < 0 || ng.first > h - 1 || ng.second < 0 || ng.second > w - 1) continue;
t[ng.first][ng.second] = 'x';
}
now.first = next.first;
now.second = next.second;
}
rep(i, h) cout << s[i] << endl;
}
競プロするわりとねこ