QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#302595 | #7606. Digital Nim | defyers# | WA | 1ms | 4248kb | C++20 | 2.0kb | 2024-01-10 23:59:00 | 2024-01-10 23:59:00 |
Judging History
answer
#include "bits/stdc++.h"
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
using ll = long long;
using LL = long long;
using pii = pair<int, int>;
#define int long long
const int K = 20;
struct Func{
int to[K] = {};
};
Func operator* (const Func& f, const Func& g){
Func h;
for(int i = 0; i < K; i++){
h.to[i] = g.to[f.to[i]];
}
return h;
}
Func Id(){
Func f;
for(int i = 0; i < K; i++){
f.to[i] = i;
}
return f;
}
int s(LL y){
int _s = 0;
while(y){
_s += y % 10;
y /= 10;
}
return _s;
}
int R(LL y){
return s(y) / 10;
}
Func CT(int k){
Func f;
for(int i = 0; i < K; i++){
if(i < k) f.to[i] = i + 1;
else f.to[i] = 0;
}
return f;
}
Func f[K][K * 10];
void solve(int TC) {
for(int i = 0; i < K * 10; i++){
f[0][i] = CT(i / 10);
}
for(int j = 1; j < K; j++){
for(int pf = 0; pf < (K - 1) * 10; pf++){
Func g = Id();
for(int k = pf; k < pf + 10; k++){
g = g * f[j - 1][k];
// for(int k = 0; k < K; k++){
// cout << g.to[k] << ' ';
// }
// cout << '\n';
}
f[j][pf] = g;
// for(int k = 0; k < K; k++){
// cout << f[j][pf].to[k] << ' ';
// }
// cout << '\n';
}
}
int n; cin >> n;
for(int i = 0; i < n; i++){
int x; cin >> x;
if(x % 10){
cout << "Algosia" << '\n';
continue;
}
x /= 10;
int a[K] = {}, ps[K] = {};
int d = 0;
while(x){
a[d++] = x % 10; x /= 10;
}
for(int i = d - 1; i >= 0; i--){
ps[i] = ps[i + 1] + a[i];
}
Func g = Id();
for(int i = d - 1; i >= 0; i--){
for(int j = 0; j < a[i]; j++){
g = g * f[i][ps[i + 1] + j];
}
}
g = g * f[0][ps[0]];
// for(int i = 0; i < K; i++) cout << g.to[i] << ' '; cout << '\n';
cout << (g.to[0] ? "Bajtex" : "Algosia") << '\n';
}
}
int32_t main() {
cin.tie(0)->sync_with_stdio(0);
cout << fixed << setprecision(10);
int t = 1;
// cin >> t;
for (int i = 1; i <= t; i++) {
solve(i);
}
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 4248kb
input:
4 1 10 42 190
output:
Algosia Algosia Algosia Bajtex
result:
wrong answer 2nd lines differ - expected: 'Bajtek', found: 'Algosia'