답안 #863944

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
863944 2023-10-21T14:06:41 Z Unforgettablepl Mensza (COI22_mensza) C++17
34 / 100
3001 ms 151312 KB
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
/*
ID: samikgo1
TASK: wormhole
LANG: C++
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
//#define f first
//#define s second
//#define x first
//#define y second
const int INF = 1e9;
const ll modulo = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#define int ll

void encode1(){
    int x;cin>>x;
    vector<int> ans;
    for(int i=0;i<10;i++){
        if(x&(1<<(i)))for(int j=0;j<2*i+1;j++)ans.emplace_back(2*i+1);
    }
    cout << ans.size() << ' ';
    for(int&a:ans)cout<<a<<' ';
    cout << '\n';
}
void encode2(){
    int x;cin>>x;
    vector<int> ans;
    for(int i=0;i<10;i++){
        if(x&(1<<i))for(int j=0;j<2*i+2;j++)ans.emplace_back(2*i+2);
    }
    cout << ans.size() << ' ';
    for(int&a:ans)cout<<a<<' ';
    cout << '\n';
}

void decode(){
    int a = 0;
    int b = 0;
    int l;cin>>l;
    vector<int> arr(l);
    for(int&i:arr)cin>>i;
    for(int&i:arr){
        if(i%2){
            i = (i-1)/2;
            a|=(1<<i);
        } else {
            i = (i-2)/2;
            b|=(1<<i);
        }
    }
    if(a<b)cout<<"B\n";
    else cout<<"A\n";
}

void solve(){
    int l,Q;
    cin >> l >> Q;
    for (int i = 0; i < Q; i++) {
        string a;cin>>a;
        switch(a[0]){
            case 'a':
                encode1();
                break;
            case 'b':
                encode2();
                break;
            case 'c':
                decode();
                break;
        }
    }
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
//    int t;
//    cin >> t;
//    while(t--)
//    for(int i=1;i<=1000;i++){
//        if(encode2(i)>110)cout << i << ' ';
//    }
//    cout << endl;
    solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 784 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 584 ms 3176 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3001 ms 151312 KB Integer parameter [name=l_46] equals to 22, violates the range [0, 20]
2 Halted 0 ms 0 KB -