結果
| 問題 |
No.2247 01 ZigZag
|
| コンテスト | |
| ユーザー |
kcvlex
|
| 提出日時 | 2023-03-17 21:41:08 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,005 bytes |
| コンパイル時間 | 4,260 ms |
| コンパイル使用メモリ | 149,980 KB |
| 最終ジャッジ日時 | 2025-02-11 12:46:05 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 46 WA * 4 |
ソースコード
#include <iostream>
#include <atcoder/all>
#define ALL(V) std::begin(V), std::end(V)
std::string solve(int N, int M, int K) {
if (N == 0 || M == 0) {
if (K == 0) {
char c = '0' + (M == 0);
return std::string(N + M, c);
} else {
return "-1";
}
}
if (K == 0) return "-1";
int max = std::min(N, M) * 2 - (N == M);
if (max < K) return "-1";
if (K == max && N < M) {
std::string s;
for (int i = 0; i < N; i++) s += "10";
s += std::string(M - N, '1');
return s;
}
std::string ans = "01";
N--; M--; K--;
while (2 <= K) {
assert(N && M);
ans += "01";
K -= 2;
N--; M--;
}
ans += std::string(M, '1');
if (K == 1) {
assert(N);
ans += '0';
N--;
}
return std::string(N, '0') + ans;
}
int main() {
int N, M, K;
std::cin >> N >> M >> K;
std::cout << solve(N, M, K) << std::endl;
return 0;
}
kcvlex