#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int q,l;
cin>>l>>q;
while(q--){
string s;
cin>>s;
if(s[0]=='a'){
int n;
cin>>n;
n+=(1<<20);
vector<int> ans;
while(n>1){
if(n&1) ans.push_back(n);
n>>=1;
}
cout<<ans.size()<<" ";
for(auto x:ans) cout<<x<<" ";
cout<<"\n";
}
else if(s[0]=='b'){
int n;
cin>>n;
n+=(1<<20);
vector<int> ans;
while(n>1){
if(n%2==0) ans.push_back(n^1);
n>>=1;
}
cout<<ans.size()<<" ";
for(auto x:ans) cout<<x<<" ";
cout<<"\n";
}
else{
int n;
cin>>n;
vector<int> vec(n);
for(auto &x:vec) cin>>x;
bool flag=0;
for(auto x:vec){
if(x==2) flag=1;
}
if(flag) cout<<"A\n";
else cout<<"B\n";
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
9 ms |
700 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
851 ms |
2832 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1818 ms |
106184 KB |
Output is correct |