QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#232782 | #7606. Digital Nim | ucup-team2230 | WA | 5ms | 6636kb | C++23 | 1.4kb | 2023-10-30 22:03:30 | 2023-10-30 22:03:30 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define a first
#define b second
#define pb push_back
#define eb emplace_back
#define si(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define rng(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,b) rng(i,0,b)
using ll=long long;
using P=pair<int,int>;
#define tct template<class t>
#define tctu template<class t,class u>
tct using vc=vector<t>;
tctu bool chmax(t&a,u b){if(a<b){a=b;return 1;}return 0;}
tctu bool chmin(t&a,u b){if(a>b){a=b;return 1;}return 0;}
int dp[200][20][200];
void solve2(){
ll n; cin >> n;
if(n%10){
cout << "Algosia\n";
return;
}
string s="";
while(n){
s.pb('0'+n%10);
n/=10;
}
reverse(s.begin(),s.end());
int pre = 0;
rep(i,si(s)-1){
int val = s[i]-'0';
int sum = 0;
rep(j,i) sum+=(s[j]-'0');
rep(j,val){
pre = dp[sum+j][si(s)-1-i][pre];
if(sum+j+1 < pre+1) pre = 0;
}
}
cout<<(!pre?"Bajtek":"Algosia")<<'\n';
}
void solve(){
rep(s,180){
rep(pre,180){
int np = pre;
rng(i,1,10){
np++;
if(s+i < np) np = 0;
}
dp[s][1][pre] = np;
}
}
rng(d,2,20){
rep(s,180){
rep(pre,180){
int np = pre;
rep(nxt,10){
np = dp[s+nxt][d-1][np];
if(nxt != 9){
if(s+nxt+1 < np+1) np = 0;
}
}
dp[s][d][pre] = np;
}
}
}
}
signed main(){
cin.tie(0);
ios::sync_with_stdio(0);
cout<<fixed<<setprecision(20);
solve();
int t;cin>>t;
while(t--) solve2();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 4ms
memory: 6400kb
input:
4 1 10 42 190
output:
Algosia Bajtek Algosia Algosia
result:
ok 4 lines
Test #2:
score: 0
Accepted
time: 5ms
memory: 6416kb
input:
1 1
output:
Algosia
result:
ok single line: 'Algosia'
Test #3:
score: -100
Wrong Answer
time: 5ms
memory: 6636kb
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:
wrong answer 2980th lines differ - expected: 'Bajtek', found: 'Algosia'