QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#287945 | #7979. 棋盘 | zhouhuanyi | 0 | 584ms | 3808kb | C++20 | 6.7kb | 2023-12-21 12:28:05 | 2023-12-21 12:28:05 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<vector>
#define N 960
#define __builtin_ia32_adc(x,y,flag) __asm__("addb %3, %0\n\t" "adcq %2, %1\n\t" "setc %0":"+r"(flag),"+r"(x):"r"(y),"i"(-1):"cc")
using namespace std;
const long long maxn=(long long)(1e18);
int read()
{
char c=0;
int sum=0;
while (c<'0'||c>'9') c=getchar();
while ('0'<=c&&c<='9') sum=sum*10+c-'0',c=getchar();
return sum;
}
struct bigint{
typedef unsigned long long u64;
typedef unsigned __int128 u128;
typedef std::size_t st;
std::vector<u64> data;
bigint(){}
bigint(u64 x):data(x?std::vector<u64>{x}:std::vector<u64>{}){}
bigint(const std::string &s){
st pos=s.length();
int cnt=0;
u64 val=0;
while(pos){
pos--;
if(cnt==64){
data.push_back(val);
val=0;cnt=0;
}
val|=(u64)(s[pos]=='1')<<cnt;
++cnt;
}
if(cnt&&val)data.push_back(val);
}
explicit operator std::string()const{
if(data.empty())return "0";
bool t=0;
std::string ret;
for(int i=63;i>=0;i--){
t|=(data.back()>>i)&1;
if(t)ret+='0'|((data.back()>>i)&1);
}
st i=data.size()-1;
while(i){
i--;
for(int j=63;j>=0;j--)ret+='0'|((data[i]>>j)&1);
}
return ret;
}
explicit operator bool()const{return !data.empty();}
explicit operator u64()const{return data.empty()?0:data[0];}
st digit()const{
if(data.empty())return 0;
return (data.size()<<6)-__builtin_clzll(data.back());
}
bool operator==(const bigint &a)const{return a.data==data;}
bool operator!=(const bigint &a)const{return a.data!=data;}
bool operator<(const bigint &a)const{
if(data.size()!=a.data.size())return data.size()<a.data.size();
for(st i=data.size();i;){
i--;
if(data[i]!=a.data[i])return data[i]<a.data[i];
}
return 0;
}
bool operator>(const bigint &a)const{return a<(*this);}
bool operator<=(const bigint &a)const{return !(*this>a);}
bool operator>=(const bigint &a)const{return !(*this<a);}
bigint &operator<<=(st n){
if(data.empty())return *this;
int w=n&63;st z=n>>6;
st i=data.size();
bool flg=0;
if(w&&(data.back()>>(64-w)))data.push_back(0),flg=1;
data.resize(data.size()+z);
while(i){
i--;
if(flg)data[i+z+1]|=data[i]>>(64-w);
data[i+z]=data[i]<<w;
flg|=bool(w);
}
for(st i=0;i<z;i++)data[i]=0;
return *this;
}
bigint &operator>>=(st n){
int w=n&63;st z=n>>6,i=0;
for(;i+z<data.size();i++){
if(w&&i)data[i-1]|=data[i+z]<<(64-w);
data[i]=data[i+z]>>w;
}
while(data.size()>i)data.pop_back();
while(!data.empty()&&data.back()==0)data.pop_back();
return *this;
}
bigint operator<<(st n)const{return bigint(*this)<<=n;}
bigint operator>>(st n)const{return bigint(*this)>>=n;}
bigint &operator+=(const bigint &a){
data.resize(std::max(data.size(),a.data.size()));
bool carry=0;
for(st i=0;i<data.size();i++){
u64 rg=0;
if(i<a.data.size())rg=a.data[i];
__builtin_ia32_adc(data[i],rg,carry);
}
if(carry)data.push_back(1);
return *this;
}
bigint &operator-=(const bigint &a){
bool carry=1;
for(st i=0;i<data.size();i++){
u64 rg=-1;
if(i<a.data.size())rg=~a.data[i];
__builtin_ia32_adc(data[i],rg,carry);
}
while(!data.empty()&&data.back()==0)data.pop_back();
return *this;
}
bigint &operator++(){return *this+=bigint(1);}
bigint &operator--(){return *this-=bigint(1);}
bigint operator++(int){bigint tmp=*this;++*this;return tmp;}
bigint operator--(int){bigint tmp=*this;--*this;return tmp;}
bigint &operator*=(const bigint &a){
std::vector<u64> ret(data.size()+a.data.size());
for(st i=0;i<data.size();i++){
u64 carry=0;bool wcarry=0;
st k=i;
for(st j=0;j<a.data.size();j++,k++){
u128 r=data[i]*(u128)a.data[j]+carry;
u64 cur=r;
carry=r>>64;
__builtin_ia32_adc(ret[k],cur,wcarry);
}
while(carry||wcarry){
__builtin_ia32_adc(ret[k],carry,wcarry);
carry=0;k++;
}
}
while(!ret.empty()&&ret.back()==0)ret.pop_back();
data=ret;
return *this;
}
bigint &operator/=(const bigint &a){
if(a.digit()>digit()){
data.clear();
return *this;
}
st z=digit()-a.digit();
std::vector<u64> ret;
while(1){
bigint tmp=a<<z;
if(tmp<=*this){
*this-=tmp;
st v1=z>>6;
if(ret.size()<=v1)ret.resize(v1+1);
ret[v1]|=(u64)(1)<<(z&63);
}
if(!z)break;
z--;
}
data=ret;
return *this;
}
bigint &operator%=(const bigint &a){
if(a.digit()>digit())return *this;
st z=digit()-a.digit();
while(1){
bigint tmp=a<<z;
if(tmp<=*this)*this-=tmp;
if(!z)break;
z--;
}
return *this;
}
bigint operator+(const bigint &a)const{return bigint(*this)+=a;}
bigint operator-(const bigint &a)const{return bigint(*this)-=a;}
bigint operator*(const bigint &a)const{return bigint(*this)*=a;}
bigint operator/(const bigint &a)const{return bigint(*this)/=a;}
bigint operator%(const bigint &a)const{return bigint(*this)%=a;}
};
std::istream &operator>>(std::istream &st,bigint &a){
std::string s;st>>s;a=bigint(s);return st;
}
std::ostream &operator<<(std::ostream &st,const bigint &a){
return st<<(std::string)(a);
}
bigint F[N+1];
int k,q,x,y;
bool used[N+1];
int main()
{
string s;
bigint maxn=1,n;
for (int i=1;i<=100;++i) maxn*=10;
F[1]=1;
for (int i=2;i<=480;++i) F[i]=F[i-1]+F[i-2];
for (int i=1;i<=240;++i)
{
printf("%d %d\n",i,i);
printf("%d %d\n",i+1,i);
printf("%d %d\n",i,i+1);
printf("%d %d\n",i,i+2);
}
k=read(),q=read(),x=read(),y=read();
while (q--)
{
n=0,cin>>s;
for (int i=0;i<s.length();++i) n=n*bigint(10)+s[i]-'0';
for (int i=1;i<=960;++i) used[i]=0;
for (int i=480;i>=1;--i)
if (n>=F[i])
n=n-F[i],used[i<<1]=1;
for (int i=1;i<=960;++i) printf("%d",used[i]);
puts("");
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 37ms
memory: 3808kb
input:
3 999 1000 340 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 ...
output:
1 1 2 1 1 2 1 3 2 2 3 2 2 3 2 4 3 3 4 3 3 4 3 5 4 4 5 4 4 5 4 6 5 5 6 5 5 6 5 7 6 6 7 6 6 7 6 8 7 7 8 7 7 8 7 9 8 8 9 8 8 9 8 10 9 9 10 9 9 10 9 11 10 10 11 10 10 11 10 12 11 11 12 11 11 12 11 13 12 12 13 12 12 13 12 14 13 13 14 13 13 14 13 15 14 14 15 14 14 15 14 16 15 15 16 15 15 16 15 17 16 16 17...
result:
wrong answer Integer 2 violates the range [1, 1]
Subtask #2:
score: 0
Wrong Answer
Test #2:
score: 0
Wrong Answer
time: 366ms
memory: 3784kb
input:
12 10000 1000 340 358908473750 36343501002 904324605639 453955046266 725478753662 218319365131 882878650993 648345848966 474401697383 722377018680 718743783955 748051292505 167886140898 411111004914 327825244967 990026144963 623309580364 970889332700 319445927842 527624602835 453135227321 1153226125...
output:
1 1 2 1 1 2 1 3 2 2 3 2 2 3 2 4 3 3 4 3 3 4 3 5 4 4 5 4 4 5 4 6 5 5 6 5 5 6 5 7 6 6 7 6 6 7 6 8 7 7 8 7 7 8 7 9 8 8 9 8 8 9 8 10 9 9 10 9 9 10 9 11 10 10 11 10 10 11 10 12 11 11 12 11 11 12 11 13 12 12 13 12 12 13 12 14 13 13 14 13 13 14 13 15 14 14 15 14 14 15 14 16 15 15 16 15 15 16 15 17 16 16 17...
result:
wrong answer Integer 2 violates the range [1, 1]
Subtask #3:
score: 0
Wrong Answer
Test #5:
score: 0
Wrong Answer
time: 572ms
memory: 3780kb
input:
100 10000 1000 340 87490023455826213450979333037504606824522062808297739018786336978222089712660133428564103979384831 874900289913204769749000879539227331559680630241808944569515663934025397982898503777823815274323967 8749002899116133353924895735921513229471979456689635148877567298640178774668643967...
output:
1 1 2 1 1 2 1 3 2 2 3 2 2 3 2 4 3 3 4 3 3 4 3 5 4 4 5 4 4 5 4 6 5 5 6 5 5 6 5 7 6 6 7 6 6 7 6 8 7 7 8 7 7 8 7 9 8 8 9 8 8 9 8 10 9 9 10 9 9 10 9 11 10 10 11 10 10 11 10 12 11 11 12 11 11 12 11 13 12 12 13 12 12 13 12 14 13 13 14 13 13 14 13 15 14 14 15 14 14 15 14 16 15 15 16 15 15 16 15 17 16 16 17...
result:
wrong answer Integer 2 violates the range [1, 1]
Subtask #4:
score: 0
Wrong Answer
Test #7:
score: 0
Wrong Answer
time: 584ms
memory: 3768kb
input:
100 10000 990 310 4083451712318559926139496762164571032902328806667934236880329773320213539959944736095945843081512968 7811890641057562314768022152641517082686481268288006737090208624016586608183953908313798353213188661 97358161226180890688421784730819518002666166790210320310558753031161862165361257...
output:
1 1 2 1 1 2 1 3 2 2 3 2 2 3 2 4 3 3 4 3 3 4 3 5 4 4 5 4 4 5 4 6 5 5 6 5 5 6 5 7 6 6 7 6 6 7 6 8 7 7 8 7 7 8 7 9 8 8 9 8 8 9 8 10 9 9 10 9 9 10 9 11 10 10 11 10 10 11 10 12 11 11 12 11 11 12 11 13 12 12 13 12 12 13 12 14 13 13 14 13 13 14 13 15 14 14 15 14 14 15 14 16 15 15 16 15 15 16 15 17 16 16 17...
result:
wrong answer Integer 2 violates the range [1, 1]
Subtask #5:
score: 0
Wrong Answer
Test #9:
score: 0
Wrong Answer
time: 581ms
memory: 3808kb
input:
100 10000 1050 260 8749002899132047697490008908470485461412677723566863434996575047286849703722697797645542008396185599 8749002899132047697490008908470485461412677699052921091826559946707718798046219210886366418022957055 7655377536740541735303757766642121742076255665128332760334129720709510994307378...
output:
1 1 2 1 1 2 1 3 2 2 3 2 2 3 2 4 3 3 4 3 3 4 3 5 4 4 5 4 4 5 4 6 5 5 6 5 5 6 5 7 6 6 7 6 6 7 6 8 7 7 8 7 7 8 7 9 8 8 9 8 8 9 8 10 9 9 10 9 9 10 9 11 10 10 11 10 10 11 10 12 11 11 12 11 11 12 11 13 12 12 13 12 12 13 12 14 13 13 14 13 13 14 13 15 14 14 15 14 14 15 14 16 15 15 16 15 15 16 15 17 16 16 17...
result:
wrong answer Integer 2 violates the range [1, 1]
Subtask #6:
score: 0
Wrong Answer
Test #11:
score: 0
Wrong Answer
time: 583ms
memory: 3792kb
input:
100 10000 1050 240 8749002899132047697490008908470485461412677723572849734285100881333676956761384191490477496469520383 874886939179415873527191365288672777702448917037688119492655525651250910013304087281579324577152991 87490028991320476974900089084704854614126777235728490149522637601883528949454159...
output:
1 1 2 1 1 2 1 3 2 2 3 2 2 3 2 4 3 3 4 3 3 4 3 5 4 4 5 4 4 5 4 6 5 5 6 5 5 6 5 7 6 6 7 6 6 7 6 8 7 7 8 7 7 8 7 9 8 8 9 8 8 9 8 10 9 9 10 9 9 10 9 11 10 10 11 10 10 11 10 12 11 11 12 11 11 12 11 13 12 12 13 12 12 13 12 14 13 13 14 13 13 14 13 15 14 14 15 14 14 15 14 16 15 15 16 15 15 16 15 17 16 16 17...
result:
wrong answer Integer 2 violates the range [1, 1]
Subtask #7:
score: 0
Wrong Answer
Test #13:
score: 0
Wrong Answer
time: 1ms
memory: 3808kb
input:
100 1 980 260 8749002899132047697490008908470485461309833682610292204604841418296589481615503153703163411103219711
output:
1 1 2 1 1 2 1 3 2 2 3 2 2 3 2 4 3 3 4 3 3 4 3 5 4 4 5 4 4 5 4 6 5 5 6 5 5 6 5 7 6 6 7 6 6 7 6 8 7 7 8 7 7 8 7 9 8 8 9 8 8 9 8 10 9 9 10 9 9 10 9 11 10 10 11 10 10 11 10 12 11 11 12 11 11 12 11 13 12 12 13 12 12 13 12 14 13 13 14 13 13 14 13 15 14 14 15 14 14 15 14 16 15 15 16 15 15 16 15 17 16 16 17...
result:
wrong answer Integer 2 violates the range [1, 1]
Subtask #8:
score: 0
Wrong Answer
Test #19:
score: 0
Wrong Answer
time: 584ms
memory: 3788kb
input:
100 10000 960 240 8749002899132047697015724510954438324957730968977252383122989921226002617013223698533483281626692607 8749002899132047697490008908470485461412677720507858663971304708923117942496885325656574463725010943 87148271065573131361716885470369961093519598137825155235803895087505468828694702...
output:
1 1 2 1 1 2 1 3 2 2 3 2 2 3 2 4 3 3 4 3 3 4 3 5 4 4 5 4 4 5 4 6 5 5 6 5 5 6 5 7 6 6 7 6 6 7 6 8 7 7 8 7 7 8 7 9 8 8 9 8 8 9 8 10 9 9 10 9 9 10 9 11 10 10 11 10 10 11 10 12 11 11 12 11 11 12 11 13 12 12 13 12 12 13 12 14 13 13 14 13 13 14 13 15 14 14 15 14 14 15 14 16 15 15 16 15 15 16 15 17 16 16 17...
result:
wrong answer Integer 2 violates the range [1, 1]