Submission #1210092

#TimeUsernameProblemLanguageResultExecution timeMemory
1210092FatonimMensza (COI22_mensza)C++20
0 / 100
1872 ms122000 KiB
#include <bits/stdc++.h> using namespace std; #ifdef ONPC #include "debug.h" #else #define dbg(...) #endif #define ll long long #define int long long #define ld long double #define pi pair<int, int> #define sz(a) ((int)(a.size())) #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define sqr(n) ((n) * (n)) #define divup(a, b) (((a) + (b)-1) / (b)) #define popcount(n) __builtin_popcountll(n) #define clz(n) __builtin_clzll(n) #define Fixed(a) cout << fixed << setprecision(12) << a; template <class T> bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; } template <class T> bool chmax(T& a, const T& b) { return b > a ? a = b, 1 : 0; } const int mod = 998244353; // 998244353 1e9 + 7 const ll inf = (ll)(1e18) + 7; const ld eps = 1e-9; const int B = 9; const int N = 1000 + 3; const int logn = 20; const int maxn = 2e5 + 7; /////////////////////////solve///////////////////////// int L; vector<int> decode_a(int a) { vector<int> res; for (int j = 0; j < B; ++j) { if (a >> j & 1) { for (int i = 1; i <= j + 1; ++i) { res.push_back(j + 1); } } } return res; } vector<int> decode_b(int b) { vector<int> res; for (int j = 0; j < B; ++j) { if (b >> j & 1) { for (int i = 1; i <= j + 1 + B; ++i) { res.push_back(j + 1 + B); } } } return res; } bool encode(int n, vector<int> c) { int a = 0, b = 0; for (auto x : c) { if (x <= B) { int j = x - 1; a += 1 << j; } else { int j = x - 1 - B; b += 1 << j; } } // dbg(a, b); return a > b; } void solve() { cin >> L; int t; cin >> t; while (t--) { string cur; cin >> cur; if (cur == "alojzije") { int a; cin >> a; vector<int> res = decode_a(a); cout << sz(res) << "\n"; for (auto x : res) cout << x << " "; cout << "\n"; } else if (cur == "benjamin") { int b; cin >> b; vector<int> res = decode_b(b); cout << sz(res) << "\n"; for (auto x : res) cout << x << " "; cout << "\n"; } else { int n; cin >> n; vector<int> c(n); for (int i = 0; i < n; ++i) { cin >> c[i]; } bool res = encode(n, c); cout << (res ? "A" : "B") << "\n"; } } } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #ifdef ONPC freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); freopen("error.txt", "w", stderr); #endif solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...