QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#536353#7813. 密码锁mingjunyi100 ✓1ms4084kbC++201.6kb2024-08-29 07:10:572024-08-29 07:10:57

Judging History

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

  • [2024-08-29 07:10:57]
  • 评测
  • 测评结果:100
  • 用时:1ms
  • 内存:4084kb
  • [2024-08-29 07:10:57]
  • 提交

answer

#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;

int Turn(vector<int> nums) {
	int res = nums[0]*10000+nums[1]*1000+nums[2]*100+nums[3]*10+nums[4];
	return res;
}

set<int> has;

int main() {
	int n;
	long long sum = 0;
	cin>>n; 
	vector<int> result;
	map<int,int> trueNum;
	int loop = 1;
	while(n--) {
		sum = 0;
		int a,b,c,d,e;
		cin>>a>>b>>c>>d>>e;
		int num = a*10000+b*1000+c*100+d*10+e;
		int nums[] = {a + 10,b + 10,c + 10,d + 10,e + 10};
		has.insert(num);
		trueNum[num]++;
		//one round
		for(int i = 0;i<5;i++)
		{
			for(int j = 1;j<=9;j++) {
				result.clear();
				for(int k = 0;k<5;k++) {
					if(k == i) result.push_back((nums[i]-j)%10);
					if(k != i)result.push_back(nums[k]%10);
				}
				int numk = Turn(result);
				
				if(trueNum[numk] == loop-1&&!has.count(numk)&&loop>1) {
					trueNum[numk]++;
					sum++;
				}
				else if((trueNum[numk] == loop-1)&&!has.count(numk)&&loop == 1) {
					trueNum[numk]++;
					sum++;
				}
			}
		}
		//two
		for(int i = 0;i<4;i++) {
			for(int j = 1;j<=9;j++) {
				result.clear();
				for(int k = 0;k<5;k++) {
					if(k == i) {
						result.push_back((nums[i]-j)%10);
						result.push_back((nums[i+1]-j)%10);
					}
					if(k!=i&&k!=i+1) result.push_back((nums[k])%10);
				}
				int numk = Turn(result);
				if(trueNum[numk] == loop-1&&!has.count(numk)&&loop>1) {
					trueNum[numk]++;
					sum++;
				}
				if((trueNum[numk] == loop-1)&&!has.count(numk)&&loop == 1) {
					trueNum[numk]++;
					sum++;
				}
				
			}
		}
		
		loop++;
	}
	printf("%lld",sum);
	
 

	return 0;
}

詳細信息


Pretests


Final Tests

Test #1:

score: 10
Accepted
time: 0ms
memory: 3796kb

input:

1
4 9 8 2 5

output:

81

result:

ok single line: '81'

Test #2:

score: 10
Accepted
time: 0ms
memory: 3996kb

input:

1
7 7 5 2 0

output:

81

result:

ok single line: '81'

Test #3:

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

input:

1
8 9 8 7 8

output:

81

result:

ok single line: '81'

Test #4:

score: 10
Accepted
time: 0ms
memory: 3716kb

input:

2
0 3 7 3 8
0 3 6 7 8

output:

6

result:

ok single line: '6'

Test #5:

score: 10
Accepted
time: 0ms
memory: 3716kb

input:

2
7 3 7 9 7
3 3 7 9 3

output:

2

result:

ok single line: '2'

Test #6:

score: 10
Accepted
time: 0ms
memory: 3716kb

input:

4
8 6 9 9 4
8 6 8 9 4
8 6 7 9 4
8 6 1 9 4

output:

6

result:

ok single line: '6'

Test #7:

score: 10
Accepted
time: 0ms
memory: 3820kb

input:

6
0 8 3 9 0
0 4 3 9 0
0 0 3 9 0
0 3 3 9 0
0 5 3 9 0
0 6 3 9 0

output:

4

result:

ok single line: '4'

Test #8:

score: 10
Accepted
time: 1ms
memory: 3728kb

input:

7
2 2 5 6 3
1 8 5 6 3
2 8 7 6 3
2 8 6 6 3
2 8 8 6 3
2 1 5 6 3
2 8 9 6 3

output:

1

result:

ok single line: '1'

Test #9:

score: 10
Accepted
time: 0ms
memory: 4084kb

input:

5
6 6 6 9 5
6 0 0 9 5
6 1 1 9 5
6 2 2 9 5
6 4 4 9 5

output:

5

result:

ok single line: '5'

Test #10:

score: 10
Accepted
time: 0ms
memory: 3812kb

input:

8
9 0 8 6 0
9 5 2 6 0
9 0 7 0 4
9 0 9 6 0
3 0 7 6 0
9 0 7 6 7
4 0 7 6 0
9 8 7 6 0

output:

1

result:

ok single line: '1'