結果
問題 | No.2247 01 ZigZag |
ユーザー | Yasser Hussain |
提出日時 | 2023-03-17 22:06:13 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 6,667 bytes |
コンパイル時間 | 2,309 ms |
コンパイル使用メモリ | 207,900 KB |
実行使用メモリ | 814,596 KB |
最終ジャッジ日時 | 2024-09-18 11:07:44 |
合計ジャッジ時間 | 5,308 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | AC | 2 ms
6,944 KB |
testcase_03 | WA | - |
testcase_04 | AC | 2 ms
6,940 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 2 ms
6,944 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | AC | 2 ms
6,940 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | AC | 2 ms
6,940 KB |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | AC | 2 ms
6,944 KB |
testcase_19 | AC | 2 ms
6,944 KB |
testcase_20 | AC | 2 ms
6,944 KB |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | AC | 2 ms
6,940 KB |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | AC | 2 ms
6,940 KB |
testcase_32 | AC | 4 ms
6,944 KB |
testcase_33 | AC | 3 ms
6,940 KB |
testcase_34 | AC | 3 ms
6,940 KB |
testcase_35 | AC | 3 ms
6,944 KB |
testcase_36 | AC | 3 ms
6,944 KB |
testcase_37 | AC | 3 ms
6,944 KB |
testcase_38 | AC | 3 ms
6,940 KB |
testcase_39 | AC | 3 ms
6,940 KB |
testcase_40 | AC | 2 ms
6,944 KB |
testcase_41 | AC | 2 ms
6,940 KB |
testcase_42 | AC | 2 ms
6,944 KB |
testcase_43 | AC | 2 ms
6,944 KB |
testcase_44 | AC | 2 ms
6,940 KB |
testcase_45 | MLE | - |
testcase_46 | -- | - |
testcase_47 | -- | - |
testcase_48 | -- | - |
testcase_49 | -- | - |
testcase_50 | -- | - |
testcase_51 | -- | - |
コンパイルメッセージ
main.cpp: In function 'void solve()': main.cpp:134:38: warning: 'p' may be used uninitialized [-Wmaybe-uninitialized] 134 | for (int i = 0; i < (p ? m : n); i++) { | ^ main.cpp:121:21: note: 'p' declared here 121 | int p; | ^
ソースコード
#include<bits/stdc++.h> #define unless(x) if (!(x)) #define pb push_back #define eb emplace_back /* #define f first */ /* #define s second */ #define lb lower_bound #define ub upper_bound #define ins insert #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define mem(x, y) memset(x, y, sizeof(x)) #define sz(x) ((int) (x).size()) #define popcount __builtin_popcountll using namespace std; using ll = long long; using ld = long double; using pi = pair<int, int>; using pll = pair<ll, ll>; using vi = vector<int>; using vll = vector<ll>; using vpi = vector<pi>; using vpll = vector<pll>; using vvi = vector<vector<int>>; using vvll = vector<vector<ll>>; template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>; template<typename T> using maxpq = priority_queue<T, vector<T>, less<T>>; // *INDENT-OFF* template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; } template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; } void __print(int x) { cerr << x; } void __print(long x) { cerr << x; } void __print(long long x) { cerr << x; } void __print(unsigned x) { cerr << x; } void __print(unsigned long x) { cerr << x; } void __print(unsigned long long x) { cerr << x; } void __print(float x) { cerr << x; } void __print(double x) { cerr << x; } void __print(long double x) { cerr << x; } void __print(char x) { cerr << '\'' << x << '\''; } void __print(const char *x) { cerr << '\"' << x << '\"'; } void __print(const string &x) { cerr << '\"' << x << '\"'; } void __print(bool x) { cerr << (x ? "true" : "false"); } template<typename T, typename V> void __print(const pair<T, V> &x) { cerr << '{'; __print(x.first); cerr << ", "; __print(x.second); cerr << '}'; } template<size_t I = 0, typename... Tp> void __print_tup(const tuple<Tp...>& t) { cerr << get<I>(t); if constexpr(I < sizeof...(Tp) - 1) { cerr << ", "; __print_tup<I+1>(t); } } template<typename... Tp> void __print(const tuple<Tp...>& t) { cerr << '{'; __print_tup(t); cerr << '}'; } template<typename T> void __print(const T &x) { int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? ", " : ""), __print(i); cerr << "}"; } void _print() { cerr << "]\n"; } template <typename T, typename... V> void _print(T t, V... v) { __print(t); if (sizeof...(v)) cerr << ", "; _print(v...); } template<typename T> T fdiv(T x, T y) { T q = x / y; T r = x % y; if ((r != 0) && ((r < 0) != (y < 0))) --q; return q; } template<typename T> T cdiv(T x, T y) { return x / y + ((x % y != 0) ? !((x > 0) ^ (y > 0)) : 0); } namespace std { template<class Fun> class y_combinator_result { Fun fun_; public: template<class T> explicit y_combinator_result(T &&fun): fun_(std::forward<T>(fun)) {} template<class ...Args> decltype(auto) operator()(Args &&...args) { return fun_(std::ref(*this), std::forward<Args>(args)...); } }; template<class Fun> decltype(auto) yy(Fun &&fun) { return y_combinator_result<std::decay_t<Fun>>(std::forward<Fun>(fun)); } } template<typename T1, typename T2> /* cin >> pair<T1, T2> */ istream& operator>>(istream &istream, pair<T1, T2> &p) { return (istream >> p.first >> p.second); } template<typename T> /* cin >> vector<T> */ istream& operator>>(istream &istream, vector<T> &v) { for (auto &it : v) cin >> it; return istream; } template<typename T1, typename T2> /* cout << pair<T1, T2> */ ostream& operator<<(ostream &ostream, const pair<T1, T2> &p) { return (ostream << p.first << " " << p.second); } template<typename T> /* cout << vector<T> */ ostream& operator<<(ostream &ostream, const vector<T> &c) { for (auto &it : c) cout << it << " "; return ostream; } ll sum_n(int n) { return (ll) n * (n + 1) / 2; } const string yes = "Yes"; const string no = "No"; #ifdef LOCAL #define dbg(x...) cerr << "\e[1;31m"<<__func__<<":"<<__LINE__<<" [" << #x << "] = ["; _print(x); cerr << "\e[0m"; #else #define dbg(x...) #endif // *INDENT-ON* // YOU ARE ACTUALLY **SUPPOSED** TO READ THE FOLLOWING. // No need to hurry. Relax. // Read Problems Carefully. (Please do this, you keep making mistakes because you avoided this.) // Read both the input sizes (i.e. n <= 1e5, etc) and the sum of n thing. (i.e. sum of n <= 1e6, etc). // Be Careful about input data size. You keep inputting data as int, when long long was required. // Don't force some technique on a problem. BS does not solve everything. On many occasions, greedy rules. // Declare double values as long double or ld (NEVER double, because of precision issues) void solve() { int n, m, k; cin >> n >> m >> k; if (n == 0) { if (k == 0) { cout << string(m, '1') << '\n'; } else { cout << -1 << '\n'; } } else if (m == 0) { if (k == 0) { cout << string(n, '0') << '\n'; } else { cout << -1 << '\n'; } } else { vi ans; if (n == m) { if (k < 1 || k > 2 * n - 1) { cout << -1 << '\n'; return; } else { ans.pb(0); n--; int p = 1; for (int i = 0; i < k - 1; i++) { p ^= 1; ans.pb(p); p ? m-- : n--; } for (int i = 0; i < p ? m : n; i++) { ans.pb(p); } p ^= 1; for (int i = 0; i < p ? m : n; i++) { ans.pb(p); } } } else { if (k < 1 || k > 2 * min(n, m)) { cout << -1 << '\n'; return; } else { int p; if (n > m) { ans.pb(0); n--; } else { ans.pb(1); m--; } for (int i = 0; i < k - 1; i++) { p ^= 1; ans.pb(p); p ? m-- : n--; } for (int i = 0; i < (p ? m : n); i++) { ans.pb(p); } p ^= 1; for (int i = 0; i < (p ? m : n); i++) { ans.pb(p); } } } string s1, s2; for (auto x : ans) { s1 += char('0' + x); } s2 = s1; reverse(all(s2)); if (s1 < s2) { cout << s1 << '\n'; } else { cout << s2 << '\n'; } } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int t = 1; /* cin >> t; */ while (t--) { solve(); } return 0; }