QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#490866#8632. 算式密码锁KiharaTouma#95 4ms3948kbC++231.3kb2024-07-25 16:36:382024-07-25 16:36:39

Judging History

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

  • [2024-07-25 16:36:39]
  • 评测
  • 测评结果:95
  • 用时:4ms
  • 内存:3948kb
  • [2024-07-25 16:36:38]
  • 提交

answer

//qoj8632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int n;
char s[6][23];

int calc(int a, int b, int c, int d, int e, int f){
	int x = s[0][a] - '0', y = s[2][c] - '0', z = (s[4][e] - '0') * 10 + s[5][f] - '0';
	if(x == 0 && y == 0 && s[1][b] == '/') while(1);
	int le = 0, ri = z;
	if(s[1][b] == '+'){
		le = x + y;
	} else if(s[1][b] == '-'){
		le = x - y;
	} else if(s[1][b] == '*'){
		le = x * y;
	} else {
		if(y == 0 || x % y != 0){
			return 0;
		}
		le = x / y;
	}
	if(s[3][d] == '='){
		return (le == ri) ? 1 : 0;
	} else if(s[3][d] == '<'){
		return (le < ri) ? 1 : 0;
	} else {
		return (le > ri) ? 1 : 0;
	}
}

int main(){
	scanf("%d", &n);
	scanf("%s", s[0]);
	scanf("%s", s[1]);
	scanf("%s", s[2]);
	scanf("%s", s[3]);
	scanf("%s", s[4]);
	scanf("%s", s[5]);
	for(int i = 0; i <= 5; ++ i){
		for(int j = 0; j < n; ++ j){
			s[i][j+n] = s[i][j];
		}
	}
	int ans = 0;
	for(int b = 0; b < n; ++ b){
		for(int c = 0; c < n; ++ c){
			for(int d = 0; d < n; ++ d){
				for(int e = 0; e < n; ++ e){
					for(int f = 0; f < n; ++ f){
						int cnt = 0;
						for(int i = 0; i < n; ++ i){
							cnt += calc(0+i, b+i, c+i, d+i, e+i, f+i);
						}
						ans = max(ans, cnt);
					}
				}
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

详细


Pretests


Final Tests

Test #1:

score: 5
Accepted
time: 0ms
memory: 3844kb

input:

1
7
+
9
=
1
6

output:

1

result:

ok single line: '1'

Test #2:

score: 5
Accepted
time: 0ms
memory: 3756kb

input:

1
3
+
8
=
4
5

output:

0

result:

ok single line: '0'

Test #3:

score: 5
Accepted
time: 0ms
memory: 3876kb

input:

1
8
+
8
<
1
5

output:

0

result:

ok single line: '0'

Test #4:

score: 5
Accepted
time: 0ms
memory: 3876kb

input:

1
5
+
6
>
1
0

output:

1

result:

ok single line: '1'

Test #5:

score: 5
Accepted
time: 0ms
memory: 3864kb

input:

1
2
*
8
=
1
6

output:

1

result:

ok single line: '1'

Test #6:

score: 5
Accepted
time: 0ms
memory: 3872kb

input:

1
8
/
3
=
0
2

output:

0

result:

ok single line: '0'

Test #7:

score: 0
Wrong Answer
time: 0ms
memory: 3876kb

input:

1
9
/
6
>
0
1

output:

0

result:

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

Test #8:

score: 5
Accepted
time: 0ms
memory: 3804kb

input:

1
7
-
7
>
7
4

output:

0

result:

ok single line: '0'

Test #9:

score: 5
Accepted
time: 0ms
memory: 3748kb

input:

1
5
+
2
<
0
9

output:

1

result:

ok single line: '1'

Test #10:

score: 5
Accepted
time: 0ms
memory: 3856kb

input:

2
32
++
47
==
10
06

output:

2

result:

ok single line: '2'

Test #11:

score: 5
Accepted
time: 0ms
memory: 3868kb

input:

2
15
++
41
==
70
61

output:

1

result:

ok single line: '1'

Test #12:

score: 5
Accepted
time: 3ms
memory: 3948kb

input:

10
5063152515
++++++++++
3643427729
==========
1729333612
7714289416

output:

1

result:

ok single line: '1'

Test #13:

score: 5
Accepted
time: 3ms
memory: 3880kb

input:

10
5699749655
++++++++++
4486705309
==========
0690847717
9735641858

output:

3

result:

ok single line: '3'

Test #14:

score: 5
Accepted
time: 3ms
memory: 3872kb

input:

10
1672370904
++++++++++
8835825976
><><=><<<<
7640932128
5621497720

output:

8

result:

ok single line: '8'

Test #15:

score: 5
Accepted
time: 3ms
memory: 3884kb

input:

10
1458060574
++++++++++
6380400163
=>>><>>=>=
7765073124
7628127469

output:

3

result:

ok single line: '3'

Test #16:

score: 5
Accepted
time: 3ms
memory: 3944kb

input:

10
2709586364
/---*/+/++
9992425165
==========
4129100709
2377293095

output:

4

result:

ok single line: '4'

Test #17:

score: 5
Accepted
time: 4ms
memory: 3860kb

input:

10
7209588823
*/*+*-++-*
6913916311
==========
5186517243
4256032489

output:

3

result:

ok single line: '3'

Test #18:

score: 5
Accepted
time: 1ms
memory: 3804kb

input:

8
74122886
-*/**+/*
44018012
>==<>>=<
04336845
12552226

output:

5

result:

ok single line: '5'

Test #19:

score: 5
Accepted
time: 2ms
memory: 3868kb

input:

9
362285771
---++*+//
894616931
<==<><<=<
770556473
084205441

output:

7

result:

ok single line: '7'

Test #20:

score: 5
Accepted
time: 4ms
memory: 3756kb

input:

10
4263385446
+-*-++++*/
8152614990
>>==<>===<
4536040292
8354005890

output:

6

result:

ok single line: '6'