QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#225025 | #7606. Digital Nim | zhaohaikun | WA | 19ms | 48216kb | C++14 | 2.2kb | 2023-10-23 21:04:55 | 2023-10-23 21:04:56 |
Judging History
answer
// MagicDark
#include <bits/stdc++.h>
#define debug cerr << "[" << __LINE__ << "] "
#define SZ(x) (int) x.size() - 1
#define all(x) x.begin(), x.end()
#define ms(x, y) memset(x, y, sizeof x)
#define F(i, x, y) for (int i = (x); i <= (y); i++)
#define DF(i, x, y) for (int i = (x); i >= (y); i--)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template <typename T> inline void chkmax(T &x, T y) { x = max(x, y); }
template <typename T> inline void chkmin(T &x, T y) { x = min(x, y); }
template <typename T> inline void read(T &x) {
x = 0; int f = 1; char c = getchar();
for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
x *= f;
}
const int N = 20, M = 11;
// bit las presum cnt
int f[N][N * M][N * M], g[N][N * M][N * M][M];
void calc(int &las, int sum) {
las = sum >= las + 1 ? las + 1 : 0;
}
void init() {
F(bit, 0, 18) {
F(las, 0, 17 * 9) {
DF(presum, 17 * 9, 0) {
int llas = las;
if (bit) {
// debug << las << endl;
F(j, 0, 9) {
llas = f[bit - 1][llas][presum + j];
if (j != 9) calc(llas, presum + j + 1);
// if (bit == 1 && las == 0 && presum == 0) debug << j << " " << llas << endl;
}
}
// g[bit][las][presum][0] = las;
g[bit][las][presum][1] = f[bit][las][presum] = llas;
F(j, 2, 9) {
int llas = g[bit][las][presum][j - 1];
calc(llas, presum + j - 1);
g[bit][las][presum][j] = f[bit][llas][presum];
}
// debug << g[bit][las][presum][9] << endl;
}
}
}
// debug << f[1][0][0] << endl;
}
void zhk() {
ll n; cin >> n;
vector <int> t;
while (n) {
t.push_back(n % 10);
n /= 10;
}
int las = 0, presum = 0;
DF(i, SZ(t), 0) if (t[i]) {
// debug << g[i][las][presum][t[i]] << " " << presum + t[i] << endl;
// debug << g[i][las][presum][t[i]] << " " << presum + t[i] << endl;
calc(las = g[i][las][presum][t[i]], presum + t[i]);
presum += t[i];
}
// debug << las << endl;
cout << (las == 0 ? "Bajtek" : "Algosia") << '\n';
}
signed main() {
init();
int _ = 1;
cin >> _;
while (_--) zhk();
return 0;
}
/* why?
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 11ms
memory: 48216kb
input:
4 1 10 42 190
output:
Algosia Bajtek Algosia Algosia
result:
ok 4 lines
Test #2:
score: 0
Accepted
time: 16ms
memory: 47696kb
input:
1 1
output:
Algosia
result:
ok single line: 'Algosia'
Test #3:
score: -100
Wrong Answer
time: 19ms
memory: 45888kb
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 290th lines differ - expected: 'Bajtek', found: 'Algosia'