QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#509908 | #7606. Digital Nim | no_RED_no_DEAD | WA | 320ms | 4912kb | C++20 | 1.1kb | 2024-08-08 19:41:43 | 2024-08-08 19:41:44 |
Judging History
answer
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
const ll N = 1e6 + 1;
const ll M = 1e9 + 7;
string s;
ll res = 1, sum = 0;
ll f[20][20][200][2];
ll cal(ll pos, ll last, ll sum, ll tight) {
if (pos == s.size()) return (sum < last) ? 1 : last + 1;
if (f[s.size() - pos][last][sum][tight] != -1) return f[s.size() - pos][last][sum][tight];
ll res = last;
for (int i = 0; i <= (tight ? (s[pos] - '0') : 9); i ++)
res = cal(pos + 1, res, sum + i, (i == (s[pos] - '0')) ? tight : 0);
// res = cal(pos + 1, res, sum, 1);
// cout << "Debug: " << s.size() - pos << ' ' << last << ' ' << sum << ' ' << tight << ' ' << res << endl;
return (f[s.size() - pos][last][sum][tight] = res);
}
void doTest(ll testID) {
cin >> s;
memset(f, -1, sizeof f);
// cout << cal(0, 1, 0, 1) << '\n';
cout << ((cal(0, 1, 0, 1) == 1) ? "Bajtek" : "Algosia") << '\n';
}
signed main() {
ios_base::sync_with_stdio(0); cin.tie(0);
int test = 1;
cin >> test;
for (int _ = 1; _ <= test; _ ++) doTest(test);
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 4912kb
input:
4 1 10 42 190
output:
Algosia Bajtek Algosia Algosia
result:
ok 4 lines
Test #2:
score: 0
Accepted
time: 1ms
memory: 4824kb
input:
1 1
output:
Algosia
result:
ok single line: 'Algosia'
Test #3:
score: 0
Accepted
time: 265ms
memory: 4880kb
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: -100
Wrong Answer
time: 320ms
memory: 4808kb
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:
wrong answer 873rd lines differ - expected: 'Bajtek', found: 'Algosia'