結果
問題 | No.2247 01 ZigZag |
ユーザー |
|
提出日時 | 2023-03-17 21:44:48 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,444 bytes |
コンパイル時間 | 663 ms |
コンパイル使用メモリ | 85,120 KB |
最終ジャッジ日時 | 2025-02-11 12:49:43 |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 28 WA * 22 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:25:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 25 | scanf("%d %d %d", &n, &m, &k); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include<stdio.h> #include<string.h> #include<stdlib.h> #include <map> #include <vector> #include <queue> #include <deque> #include <set> #include <stack> #include <algorithm> #include <array> #include <unordered_set> #include <unordered_map> #include <string> using namespace std; bool rcmp(int a, int b) { return a>b; } typedef long long LL; char ib[200004]; int main() { int n, i, m, k, x; scanf("%d %d %d", &n, &m, &k); if (n==m) x=n+n-1; else if (n<m) x=n+n; else x=m+m; if (k>x) printf("-1\n"); else if (n>0&&m>0&&k==0) printf("-1\n"); else if (k==0) { i=0; while(n) { ib[i++]='0'; n--; } while(m) { ib[i++]='1'; m--; } ib[i]=0; printf("%s\n", ib); } else { if (n>=m) { ib[0]='0'; n--; x=0; } else { ib[0]='1'; m--; x=1; } for (i=1; ; ) { if (k==1) { if (x==0) { while(n) { ib[i++]='0'; n--; } while(m) { ib[i++]='1'; m--; } } else { while(m) { ib[i++]='1'; m--; } while(n) { ib[i++]='0'; n--; } } break; } if (x==0) { ib[i++]='1'; m--; } else { ib[i++]='0'; n--; } k--; x^=1; } ib[i]=0; printf("%s\n", ib); } return 0; }