QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#302591#7607. The Doubling Game 2defyers#WA 1ms4272kbC++201.8kb2024-01-10 23:52:512024-01-10 23:52:52

Judging History

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

  • [2024-01-10 23:52:52]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:4272kb
  • [2024-01-10 23:52:51]
  • 提交

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(R(i));
	}
	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];
			}
			f[j][pf] = g;
		}
	}
	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];
			}
		}
		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: 4272kb

input:

5
1 2
1 3
1 4
4 5

output:

Algosia
Algosia
Algosia
Algosia
Algosia

result:

wrong answer 1st lines differ - expected: '21', found: 'Algosia'