結果
| 問題 |
No.2247 01 ZigZag
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-03-21 23:58:08 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 10 ms / 2,000 ms |
| コード長 | 877 bytes |
| コンパイル時間 | 1,613 ms |
| コンパイル使用メモリ | 191,724 KB |
| 最終ジャッジ日時 | 2025-02-11 15:57:59 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 50 |
ソースコード
#include <bits/stdc++.h>
using i64 = long long;
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int N, M, K;
std::cin >> N >> M >> K;
if ((N && M && K < 1) || K > std::min({2 * N, 2 * M, N + M - 1})) {
std::cout << -1 << "\n";
return 0;
}
int last = -1;
int cnt[2] = {N, M};
for (int i = 0; i < N + M; i++) {
for (int t = 0; t < 2; t++) {
if (cnt[t] == 0) {
continue;
}
int newK = K - (!t == last);
if (newK < (cnt[!t] > 0) || newK > std::min({2 * cnt[t] - 1, 2 * cnt[!t], cnt[t] + cnt[!t] - 1})) {
continue;
}
K = newK;
cnt[t] -= 1;
std::cout << t;
last = t;
break;
}
}
std::cout << "\n";
return 0;
}