QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#302594#7606. Digital Nimdefyers#WA 1ms4188kbC++202.0kb2024-01-10 23:58:312024-01-10 23:58:32

Judging History

你现在查看的是最新测评结果

  • [2024-01-10 23:58:32]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:4188kb
  • [2024-01-10 23:58:31]
  • 提交

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] ? "Algosia" : "Bajtex") << '\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);
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 4188kb

input:

4
1
10
42
190

output:

Algosia
Bajtex
Algosia
Algosia

result:

wrong answer 2nd lines differ - expected: 'Bajtek', found: 'Bajtex'