QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#316130 | #8129. Binary Sequence | ucup-team134# | AC ✓ | 231ms | 75872kb | C++17 | 4.1kb | 2024-01-27 17:38:06 | 2024-01-27 17:38:07 |
Judging History
answer
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define ll long long
#define pb push_back
#define f first
#define s second
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ld long double
#define li __int128
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>; ///find_by_order(),order_of_key()
template<int D, typename T>struct vec : public vector<vec<D - 1, T>> {template<typename... Args>vec(int n = 0, Args... args) : vector<vec<D - 1, T>>(n, vec<D - 1, T>(args...)) {}};
template<typename T>struct vec<1, T> : public vector<T> {vec(int n = 0, T val = T()) : vector<T>(n, val) {}};
template<class T1,class T2> ostream& operator<<(ostream& os, const pair<T1,T2>& a) { os << '{' << a.f << ", " << a.s << '}'; return os; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& a){os << '{';for(int i=0;i<sz(a);i++){if(i>0&&i<sz(a))os << ", ";os << a[i];}os<<'}';return os;}
template<class T> ostream& operator<<(ostream& os, const deque<T>& a){os << '{';for(int i=0;i<sz(a);i++){if(i>0&&i<sz(a))os << ", ";os << a[i];}os<<'}';return os;}
template<class T> ostream& operator<<(ostream& os, const set<T>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T> ostream& operator<<(ostream& os, const set<T,greater<T> >& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T> ostream& operator<<(ostream& os, const multiset<T>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T> ostream& operator<<(ostream& os, const multiset<T,greater<T> >& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
template<class T1,class T2> ostream& operator<<(ostream& os, const map<T1,T2>& a) {os << '{';int i=0;for(auto p:a){if(i>0&&i<sz(a))os << ", ";os << p;i++;}os << '}';return os;}
int ri(){int x;scanf("%i",&x);return x;}
void rd(int&x){scanf("%i",&x);}
void rd(long long&x){scanf("%lld",&x);}
void rd(double&x){scanf("%lf",&x);}
void rd(long double&x){scanf("%Lf",&x);}
void rd(string&x){cin>>x;}
void rd(char*x){scanf("%s",x);}
template<typename T1,typename T2>void rd(pair<T1,T2>&x){rd(x.first);rd(x.second);}
template<typename T>void rd(vector<T>&x){for(T&p:x)rd(p);}
template<typename C,typename...T>void rd(C&a,T&...args){rd(a);rd(args...);}
//istream& operator>>(istream& is,__int128& a){string s;is>>s;a=0;int i=0;bool neg=false;if(s[0]=='-')neg=true,i++;for(;i<s.size();i++)a=a*10+s[i]-'0';if(neg)a*=-1;return is;}
//ostream& operator<<(ostream& os,__int128 a){bool neg=false;if(a<0)neg=true,a*=-1;ll high=(a/(__int128)1e18);ll low=(a-(__int128)1e18*high);string res;if(neg)res+='-';if(high>0){res+=to_string(high);string temp=to_string(low);res+=string(18-temp.size(),'0');res+=temp;}else res+=to_string(low);os<<res;return os;}
const int N=1e6+5,L=40;
vector<bool> bin[N];
vector<bool> ans[L];
vector<bool> nxt(vector<bool> a){
vector<bool> ans;
ans.reserve(sz(a));
int last=0,cnt=0;
for(auto p:a){
if(p==last){
}
else{
if(cnt!=0){
for(auto p:bin[cnt]){
ans.pb(p);
}
ans.pb(last);
}
last=p;
cnt=0;
}
cnt++;
}
if(cnt!=0){
for(auto p:bin[cnt]){
ans.pb(p);
}
ans.pb(last);
}
return ans;
}
int main()
{
for(int i=1;i<N;i++){
int tr=i;
while(tr){
bin[i].pb(tr&1);
tr/=2;
}
reverse(all(bin[i]));
}
vector<bool> tr={1};
ans[1]={1};
for(int i=2;i<L;i++){
ans[i]=nxt(ans[i-1]);
}
int t=ri();
while(t--){
ll n,m;
rd(n,m);
if(n>=L){
ll diff=(n-(L-1));
if(diff&1)n=L-2;
else n=L-1;
}
if(m>=sz(ans[n])){
printf("0\n");
}
else{
printf("%i\n",ans[n][sz(ans[n])-1-m]?1:0);
}
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
详细
Test #1:
score: 100
Accepted
time: 205ms
memory: 75872kb
input:
10 4 0 4 1 4 2 4 3 4 4 4 5 4 6 6 3 6 7 118999881999119725 3
output:
1 1 0 1 1 1 0 1 1 0
result:
ok 10 numbers
Test #2:
score: 0
Accepted
time: 201ms
memory: 75716kb
input:
10 28 69772 10 7908 4 3198 4 85913 14 52729 3 20445 9 88912 17 23743 25 37356 2 97697
output:
0 0 0 0 0 0 0 0 0 0
result:
ok 10 numbers
Test #3:
score: 0
Accepted
time: 214ms
memory: 75740kb
input:
100 29 110358 18 13645 18 590344 36 550462 11 133055 8 769352 11 265432 7 158530 12 29189 2 830361 11 584395 31 693707 7 879812 19 25069 21 616926 3 85158 31 675739 17 118385 24 315535 29 59615 10 33445 17 609235 8 738138 20 209540 4 287616 32 522302 26 959741 5 453537 27 74313 28 296289 28 857972 2...
output:
0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 1 0 0 0 0 0 1 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0
result:
ok 100 numbers
Test #4:
score: 0
Accepted
time: 231ms
memory: 75740kb
input:
100000 702433635413308636 962533 864089450531108488 538792 262747333715821506 454514 859830947243984718 105219 365621373252206174 447331 890829905503831899 507146 116987306031929573 154370 157986473366693144 364746 502917586764426513 49981 874588963478161584 594867 467219058104100510 790503 11034861...
output:
1 1 1 1 1 1 1 0 1 0 1 0 1 1 1 1 0 1 1 1 1 1 0 1 0 0 0 0 1 1 1 0 0 1 1 0 0 1 0 1 1 1 1 0 0 0 0 1 1 0 0 1 0 0 1 0 1 1 1 1 1 1 1 0 1 1 1 0 0 0 1 1 1 0 1 1 1 1 1 1 0 1 0 1 1 1 0 0 0 1 0 0 1 0 1 1 1 1 1 1 0 0 0 0 0 0 0 1 0 0 1 0 1 0 1 0 1 1 0 1 1 0 1 0 0 0 1 1 0 1 1 0 0 1 1 1 1 1 0 0 0 0 0 0 1 1 1 0 0 1 ...
result:
ok 100000 numbers
Extra Test:
score: 0
Extra Test Passed