結果
問題 |
No.2247 01 ZigZag
|
ユーザー |
![]() |
提出日時 | 2023-03-17 21:40:49 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,055 bytes |
コンパイル時間 | 1,694 ms |
コンパイル使用メモリ | 192,656 KB |
最終ジャッジ日時 | 2025-02-11 12:44:51 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 20 WA * 30 |
ソースコード
#include<bits/stdc++.h> #define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i) #define rep(i,a,b) for(int i=int(a);i<int(b);++i) #define All(x) (x).begin(),(x).end() #define rAll(x) (x).rbegin(),(x).rend() using namespace std; using ll = long long; int main(){ int n[2],k; cin>>n[0]>>n[1]>>k; string s; if(n[0]>0) { s.push_back('0'); n[0]-=1; } else { s.push_back('1'); n[1] -= 1; } while (n[0] > 0 || n[1] > 0) { int num = s.back() - '0'; if (k > 1) { num ^= 1; if(n[num] > 0){ s.push_back(num + '0'); n[num]--; k--; } else { break; } } else { if(n[num] == 0) { num ^= 1; k--; } s.push_back(num+'0'); n[num]--; } } if(n[0] > 0 || n[1] > 0 || k > 0) { cout << "-1" << endl; } else { cout << s << endl; } }