QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#220478#7606. Digital Nimucup-team2303#WA 586ms95196kbC++142.6kb2023-10-20 14:22:102023-10-20 14:22:11

Judging History

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

  • [2023-10-20 14:22:11]
  • 评测
  • 测评结果:WA
  • 用时:586ms
  • 内存:95196kb
  • [2023-10-20 14:22:10]
  • 提交

answer

/*
60 + 0 + 100 + 64 = 224.
*/

#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define L(i, j, k) for (int i = (j); i <= (k); i++)
#define R(i, j, k) for (int i = (j); i >= (k); i--)
#define pb push_back
#define pii pair<int, int>
#define ll long long
inline ll read()
{
	ll sum = 0, nega = 1;
	char ch = getchar();
	while (ch > '9'||ch < '0')
	{
	    if (ch == '-') nega = -1;
		ch = getchar();
	}
	while (ch <= '9' && ch >= '0') sum = sum * 10 + ch - '0', ch = getchar();
	return sum * nega;
}
const int N = 19, M = (1 << 14) + 9;
int T, dp[2000], s[2000];
int f[16][137][M], to[137][M], k = 14;
inline int get(int y, int Mask)
{
	int pos = 86, su = 0, nw = 0;
	L(i, 86, 99)
	{
		int t = (i - 86);
		if((Mask >> t) & 1) dp[i] = 1;
		else dp[i] = 0;
		su += dp[i];
	}
	L(i, 100, 113)
	{
		while(i * 10 - y - s[i] > pos * 10) su -= dp[pos], pos++;
		if(su) dp[i] = 0;
		else dp[i] = 1, su += dp[i], nw += 1 << (i - 100);
	} return nw;
}
inline int get2(int y, int Mask)
{
	int pos = 0, su = 0, nw = 0;
	L(i, 0, 13)
	{
		if((Mask >> i) & 1) dp[i] = 1;
		else dp[i] = 0;
		su += dp[i];
	}
	L(i, 14, 99)
	{
		while(i * 10 - y - s[i] > pos * 10) su -= dp[pos], pos++;
		if(su) dp[i] = 0;
		else dp[i] = 1, su += dp[i];
		if(i >= 86 && dp[i]) nw += 1 << (i - 86);
	} return nw;
}
inline void init()
{
	L(i, 0, 1000)
	{
		int t = i;
		while(t) s[i] += t % 10, t /= 10;
	}
	L(i, 0, 135)
		L(j, 0, (1 << k) - 1) to[i][j] = get(i, j);
	L(i, 0, 135)
		L(j, 0, (1 << k) - 1) f[0][i][j] = get2(i, j);
	L(w, 1, 15)
		L(i, 0, 135 - w * 9)
			L(j, 0, (1 << k) - 1)
			{
				int nw = j;
				L(t, 0, 9)
				{
					nw = f[w - 1][i + t][nw];
					if(t < 9) nw = to[i + t + 1][nw];
				}
				f[w][i][j] = nw;
			}
	return ;
}
ll n, r, pown[19], Ma, sr;
inline int work(int Mask, int t, int y)
{
	int pos = 0, su = 0, nw = 0;
	L(i, 0, 13)
	{
		if((Mask >> i) & 1) dp[i] = 1;
		else dp[i] = 0;
		su += dp[i];
	}
	L(i, 14, 99)
	{
		while(i * 10 - y - s[i] > pos * 10) su -= dp[pos], pos++;
		if(su) dp[i] = 0;
		else dp[i] = 1, su += dp[i];
		if(i >= 86 && dp[i]) nw += 1 << (i - 86);
	} return dp[t / 10];
}
inline void solve()
{
	n = read(); r = 0; Ma = (1 << 14) - 1; sr = 0;
	pown[0] = 1;
	L(i, 1, 18) pown[i] = pown[i - 1] * 10;
	if(n % 10) {puts("Algosia"); return ;}
	R(i, 15, 0)
	{
		while(r + pown[i + 3] <= n)
		{
			Ma = f[i][sr][Ma]; r += pown[i + 3], sr++;
			Ma = to[sr][Ma];
		}
	}
	if(work(Ma, (int)(n % 1000), sr)) puts("Bajtek");
	else puts("Algosia"); return ;
}
signed main()
{
	init();
	T = read();
	L(i, 1, T) solve();
	return 0;
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 586ms
memory: 94924kb

input:

4
1
10
42
190

output:

Algosia
Bajtek
Algosia
Algosia

result:

ok 4 lines

Test #2:

score: 0
Accepted
time: 563ms
memory: 95196kb

input:

1
1

output:

Algosia

result:

ok single line: 'Algosia'

Test #3:

score: -100
Wrong Answer
time: 547ms
memory: 93072kb

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 1080th lines differ - expected: 'Bajtek', found: 'Algosia'