QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#227287 | #7606. Digital Nim | ucup-team1004# | RE | 3ms | 6856kb | C++14 | 1.4kb | 2023-10-27 10:06:50 | 2023-10-27 10:06:50 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<typename T>
ostream& operator << (ostream &out,const vector<T> &x){
if(x.empty())return out<<"[]";
out<<'['<<x[0];
for(int i=1,len=x.size();i<len;i++)out<<','<<x[i];
return out<<']';
}
template<typename T>
vector<T> ary(const T *a,int l,int r){
return vector<T>{a+l,a+1+r};
}
template<typename T>
void debug(T x){
cerr<<x<<endl;
}
template<typename T,typename ... S>
void debug(T x,S...y){
cerr<<x<<' ',debug(y...);
}
int count(ll n){
int ans=0;
for(;n;n/=10)ans+=n%10;
return ans;
}
ll nex(ll n,int s=0){
for(ll i=n+10;;i+=10){
if(i-count(i)-s>n)return i;
}
return -1;
}
const int N=20,M=200;
int T,his[N][M][M];
ll n,pw[N];
int nex(int d,int s,int i){
int las=i;
if(~his[d][s][las])return his[d][s][las];
if(d<3){
for(int x;x=nex(i,s),x<pw[d+1];i=x);
return his[d][s][las]=i-las;
}
for(;i;){
i+=nex(d-1,s+i/pw[d],i%pw[d]);
if(i/pw[d]<9)i=nex(i,s);
else break;
}
return his[d][s][las]=i-las;
}
void get(){
scanf("%lld",&n);
if(n%10){
puts("Algosia");return;
}
ll i=0;
for(int d=18;d>=3;d--){
for(;i/pw[d]%10<n/pw[d]%10;){
i+=nex(d-1,count(i/pw[d]),i%pw[d]);
i=nex(i);
}
}
for(;i<n;i=nex(i));
puts(i==n?"Bajtek":"Algosia");
// if(i^n)debug(i,n);
}
int main(){
memset(his,-1,sizeof his);
for(int i=pw[0]=1;i<=18;i++)pw[i]=pw[i-1]*10;
for(scanf("%d",&T);T--;)get();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 6728kb
input:
4 1 10 42 190
output:
Algosia Bajtek Algosia Algosia
result:
ok 4 lines
Test #2:
score: 0
Accepted
time: 1ms
memory: 6804kb
input:
1 1
output:
Algosia
result:
ok single line: 'Algosia'
Test #3:
score: 0
Accepted
time: 3ms
memory: 6784kb
input:
10000 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 99 100 10...
output:
Algosia Algosia Algosia Algosia Algosia Algosia Algosia Algosia Algosia Bajtek Algosia Algosia Algosia Algosia Algosia Algosia Algosia Algosia Algosia Bajtek Algosia Algosia Algosia Algosia Algosia Algosia Algosia Algosia Algosia Bajtek Algosia Algosia Algosia Algosia Algosia Algosia Algosia Algosia...
result:
ok 10000 lines
Test #4:
score: 0
Accepted
time: 3ms
memory: 6856kb
input:
10000 86 385 545 561 563 770 831 859 1123 1218 1423 1437 1602 1650 1884 1960 2096 2160 2330 2552 2662 2762 3359 3382 3425 3556 3606 3669 3790 3962 3980 4009 4060 4128 4418 4424 4458 4483 4510 4540 4594 4659 4704 4766 4822 4946 5073 5139 5195 5225 5267 5390 5490 5557 5885 6171 6235 6307 6371 6442 645...
output:
Algosia Algosia Algosia Algosia Algosia Algosia Algosia Algosia Algosia Algosia Algosia Algosia Algosia Algosia Algosia Bajtek Algosia Bajtek Bajtek Algosia Algosia Algosia Algosia Algosia Algosia Algosia Algosia Algosia Algosia Algosia Algosia Algosia Algosia Algosia Algosia Algosia Algosia Algosia...
result:
ok 10000 lines
Test #5:
score: -100
Runtime Error
input:
10000 63282 121076 318636 395380 405847 473533 850891 859227 876990 877183 1202581 1360154 1416399 1450189 1603717 1618175 1636686 1648221 1649807 1652127 1714183 1730743 1766595 1813769 1883327 1909563 2033458 2034831 2054278 2365137 2398438 2431649 2544385 2591344 2781989 2799879 2946371 3081362 3...