結果
問題 | No.2766 Delicious Multiply Spice |
ユーザー | wai4u |
提出日時 | 2024-05-31 22:02:04 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 6,176 bytes |
コンパイル時間 | 3,049 ms |
コンパイル使用メモリ | 222,548 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-05-31 22:02:09 |
合計ジャッジ時間 | 4,730 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | AC | 2 ms
6,944 KB |
testcase_03 | AC | 1 ms
6,940 KB |
testcase_04 | AC | 2 ms
6,940 KB |
testcase_05 | AC | 1 ms
6,944 KB |
testcase_06 | AC | 1 ms
6,944 KB |
testcase_07 | AC | 2 ms
6,940 KB |
testcase_08 | AC | 1 ms
6,940 KB |
testcase_09 | AC | 2 ms
6,940 KB |
testcase_10 | AC | 2 ms
6,940 KB |
testcase_11 | AC | 1 ms
6,944 KB |
testcase_12 | AC | 2 ms
6,944 KB |
testcase_13 | AC | 2 ms
6,944 KB |
testcase_14 | AC | 1 ms
6,944 KB |
testcase_15 | AC | 2 ms
6,940 KB |
testcase_16 | AC | 2 ms
6,940 KB |
testcase_17 | AC | 2 ms
6,940 KB |
testcase_18 | AC | 2 ms
6,940 KB |
testcase_19 | WA | - |
testcase_20 | AC | 2 ms
6,944 KB |
testcase_21 | AC | 1 ms
6,940 KB |
testcase_22 | RE | - |
testcase_23 | RE | - |
testcase_24 | RE | - |
testcase_25 | AC | 2 ms
6,944 KB |
testcase_26 | AC | 2 ms
6,940 KB |
testcase_27 | WA | - |
testcase_28 | RE | - |
testcase_29 | WA | - |
testcase_30 | AC | 1 ms
6,944 KB |
testcase_31 | AC | 2 ms
6,940 KB |
testcase_32 | RE | - |
testcase_33 | RE | - |
testcase_34 | RE | - |
testcase_35 | RE | - |
testcase_36 | WA | - |
testcase_37 | AC | 2 ms
6,944 KB |
testcase_38 | AC | 1 ms
6,940 KB |
ソースコード
#pragma GCC optimize("Ofast,unroll-loops") #include <bits/stdc++.h> using namespace std; using ll = long long; using i128 = __int128; #include <vector> using namespace std; template <class T> using vec = vector<T>; template <class T> using vec2 = vec<vec<T>>; template <class T> using vec3 = vec<vec2<T>>; template <class T> using vec4 = vec<vec3<T>>; template <class T> using vec5 = vec<vec4<T>>; #define VEC(T, a, ...) vec<T> a(__VA_ARGS__) #define VEC2(T, a, n, ...) vector a(n, vec<T>(__VA_ARGS__)); #define VEC3(T, a, n, m, ...) \ vector a(n, vector(m, vec<T>(__VA_ARGS__))); #define VEC4(T, a, n, m, l, ...) \ vector a(n, vector(m, vector(l, vec<T>(__VA_ARGS__)))); #define all(a) (a).begin(), (a).end() #define len(a) (int)a.size() // https://cpprefjp.github.io/lang/cpp11/variadic_macros.html // https://trap.jp/post/1224/ #define eval_0(a, ...) a #define eval_1(a, b, ...) b #define eval_2(a, b, c, ...) c #define eval_3(a, b, c, d, ...) d #define eval_4(a, b, c, d, e, ...) e #define eval_5(a, b, c, d, e, f, ...) f #define eval_6(a, b, c, d, e, f, g, ...) g #define rep(t) for (int __ = 0; __ < t; __++) #define FOR_1(i, n) for (int i = 0; i < n; i++) #define FOR_2(i, a, b) for (ll i = a; i < b; i++) #define FOR_3(i, a, b, c) for (ll i = a; i < b; i += c) #define FOR(...) \ eval_4(__VA_ARGS__, FOR_3, FOR_2, FOR_1, rep)(__VA_ARGS__) #define FORR_1(i, n) for (int i = n; i-- > 0;) #define FORR_2(i, a, b) for (ll i = b; i-- > a;) #define FORR_3(i, a, b, c) for (ll i = b - 1; i >= a; i -= c) #define FORR(...) \ eval_4(__VA_ARGS__, FORR_3, FORR_2, FORR_1)(__VA_ARGS__) #define loop while (1) #define pb push_back #define eb emplace_back #include <iostream> using namespace std; void enable_fast_io() { ios::sync_with_stdio(0); cin.tie(0); } template <class T> T max(const vec<T> &a) { return *max_element(all(a)); } template <class T> T min(const vec<T> &a) { return *min_element(all(a)); } template <class T, class U> T sum(const vec<U> &a) { // return accumulate(all(a), 0ll); return accumulate(all(a), T(0)); } template <class T, class U> bool chmax(T &a, const U &b) { return b > a ? a = b, 1 : 0; } template <class T, class U> bool chmin(T &a, const U &b) { return b < a ? a = b, 1 : 0; } #define iter_1(a, A) for (auto &&a : A) #define iter_2(a, b, A) for (auto &&[a, b] : A) #define iter_3(a, b, c, A) for (auto &&[a, b, c] : A) #define iter_4(a, b, c, d, A) for (auto &&[a, b, c, d] : A) #define iter_5(a, b, c, d, e, A) \ for (auto &&[a, b, c, d, e] : A) #define iter(...) \ eval_6(__VA_ARGS__, iter_5, iter_4, iter_3, iter_2, iter_1)( \ __VA_ARGS__ \ ) #include <bits/stdc++.h> using namespace std; template <typename T, typename U> istream &operator>>(istream &in, pair<T, U> &p) { return in >> p.first >> p.second; } #include <bits/stdc++.h> using namespace std; template <typename T, typename U> ostream &operator<<(ostream &out, pair<T, U> &p) { out << p.first << ' ' << p.second; return out; } template <int k = 0, class T> void read_tup(istream &in, T &x) { if constexpr (tuple_size<T>::value > k) { in >> get<k>(x); read_tup<k + 1>(in, x); } } template <class... T> istream &operator>>(istream &in, tuple<T...> &x) { read_tup(in, x); return in; } template <int k = 0, class T> void out_tup(ostream &out, T &x) { if constexpr (tuple_size<T>::value > k) { if constexpr (k > 0) { out << ' '; } out << get<k>(x); out_tup<k + 1>(out, x); } } template <class... T> ostream &operator<<(ostream &out, tuple<T...> &x) { out_tup(out, x); return out; } #include <bits/stdc++.h> using namespace std; template <typename T> auto operator>>(istream &in, vec<T> &a) -> istream & { iter(x, a) in >> x; return in; } template <typename T> auto operator<<(ostream &out, vec<T> a) -> ostream & { FOR(i, len(a)) { if (i) { out << ' '; } out << a[i]; } return out; } // more than 1d template <typename T> auto operator<<(ostream &out, vec2<T> a) -> ostream & { iter(x, a) out << x << '\n'; return out; } #include <iostream> using namespace std; template <typename... T> void in(T &...a) { (cin >> ... >> a); } #include <iostream> using namespace std; template <class T, class... U> void out(T a, U... b) { cout << a; ((cout << ' ' << b), ...); cout << '\n'; } #include <queue> using namespace std; template <class T> using max_queue = priority_queue<T>; #include <queue> using namespace std; template <class T> using min_queue = priority_queue<T, vec<T>, greater<T>>; #include <queue> using namespace std; template <typename T> T pop(queue<T> &q) { T v = q.front(); q.pop(); return v; } template <typename T> T pop(deque<T> &q) { T v = q.front(); q.pop_front(); return v; } template <typename T> T pop(vec<T> &q) { T v = q.back(); q.pop_back(); return v; } template <typename T> T pop(max_queue<T> &q) { T v = q.top(); q.pop(); return v; } template <typename T> T pop(min_queue<T> &q) { T v = q.top(); q.pop(); return v; } // define yes/no #define yesno(y, n) \ void y(bool f = 1) { out(f ? #y : #n); } \ void n(bool f = 1) { y(!f); } yesno(yes, no); yesno(Yes, No); yesno(YES, NO); yesno(first, second); yesno(First, Second); yesno(possible, impossible); yesno(Possible, Impossible); yesno(POSSIBLE, IMPOSSIBLE); yesno(alice, bob); yesno(Alice, Bob); yesno(takahashi, aoki); yesno(Takahashi, Aoki); void solve(); int main() { enable_fast_io(); int t = 1; // in(t); rep(t) solve(); } // #include <dsa/v1/dsa/ .hpp> template <typename F> using fn = function<F>; void solve() { ll n; in(n); fn<pair<bool, string>(ll)> f; f = [&](ll n) -> pair<bool, string> { // assert(n > 0); if (n == 1) { return {true, ""}; } if (n & 1 ^ 1) { if ((n - 1) % 3 != 0) { return {false, ""}; } auto [ok, s] = f((n - 1) / 3); if (!ok) { return {false, s}; } s += 'B'; return {true, s}; } { auto [ok, s] = f((n - 1) / 2); if (ok) { return {ok, s + 'A'}; } } assert((n - 1) % 3 == 0); auto [ok, s] = f((n - 1) / 3); // assert(ok); return {true, s + 'B'}; }; out(f(n).second); }