結果
問題 | No.2247 01 ZigZag |
ユーザー |
|
提出日時 | 2023-03-17 21:50:48 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,110 bytes |
コンパイル時間 | 1,758 ms |
コンパイル使用メモリ | 171,920 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-18 10:41:00 |
合計ジャッジ時間 | 5,597 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 RE * 1 |
other | AC * 27 WA * 1 RE * 22 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, m, k; cin >> n >> m >> k; if (m == n + 1 && k == n + m - 1) { for (int i = 0; i < n + m; i++) { if (i & 1) { cout << '0'; } else { cout << '1'; } } cout << '\n'; return 0; } vector<string> can; string x = "0"; bool ok1 = true; int kk = k, nn = n, mm = m; nn--; while (kk--) { if (x.back() == '0') { x += '1'; mm--; if (mm < 0) { ok1 = false; break; } } else { x += '0'; nn--; if (nn < 0) { ok1 = false; break; } } } if (ok1 && x.back() == '1') { can.push_back(string(nn, '0') + x + string(mm, '1')); } else if (ok1) { x.pop_back(); can.push_back(string(nn, '0') + x + string(mm, '1') + '0'); } cout << can[0] << '\n'; }