QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#782044#6621. Luggage Lockk4sum1WA 40ms3664kbC++171.4kb2024-11-25 18:36:282024-11-25 18:37:25

Judging History

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

  • [2024-11-25 18:37:25]
  • 评测
  • 测评结果:WA
  • 用时:40ms
  • 内存:3664kb
  • [2024-11-25 18:36:28]
  • 提交

answer

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

int a[15][15][15][15];
void solve()
{
	int x1,x2,x3,x4;
	int y1,y2,y3,y4;
	
	string s1,s2;
	cin>>s1>>s2;
	x1=s1[0]-'0';
	x2=s1[1]-'0';
	x3=s1[2]-'0';
	x4=s1[3]-'0';
	
	y1=s2[0]-'0';
	y2=s2[1]-'0';
	y3=s2[2]-'0';
	y4=s2[3]-'0';
	
	cout<<a[(x1-y1+10)%10][(x2-y2+10)%10][(x3-y3+10)%10][(x4-y4+10)%10]<<'\n';
}

void dfs(int a1,int a2,int a3,int a4)
{
	for(int i=0;i<=1;i++)
	{
		for(int j=0;j<=1;j++)
		{
			for(int k=0;k<=1;k++)
			{
				for(int l=0;l<=1;l++)
				{
					if(i==1&&j==0&&(k==1||l==1))
						continue;
					if(l==1&&k==0&&(i==1||j==1))
						continue;
					if(i==0&&j==0&&k==0&&l==0)
						continue;
					a[(a1+i+20)%10][(a2+j+20)%10][(a3+k+20)%10][(a4+l+20)%10]=min(a[(a1+i+20)%10][(a2+j+20)%10][(a3+k+20)%10][(a4+l+20)%10],a[a1][a2][a3][a4]+1);
					a[(a1-i+20)%10][(a2-j+20)%10][(a3-k+20)%10][(a4-l+20)%10]=min(a[(a1-i+20)%10][(a2-j+20)%10][(a3-k+20)%10][(a4-l+20)%10],a[a1][a2][a3][a4]+1);
				}
			}
		}
	}
}

signed main()
{
    for(int i=0;i<=9;i++)
	{
		for(int j=0;j<=9;j++)
		{
			for(int k=0;k<=9;k++)
			{
				for(int l=0;l<=9;l++)
				{
					a[i][j][k][l]=10000;
				}
			}
		}
	}
	
	a[0][0][0][0]=0;
	for(int i=0;i<=9;i++)
	{
		for(int j=0;j<=9;j++)
		{
			for(int k=0;k<=9;k++)
			{
				for(int l=0;l<=9;l++)
				{
					dfs(i,j,k,l);
				}
			}
		}
	}
	int t;
	cin>>t;
	while(t--)
	{
		solve();
	}
} 

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3612kb

input:

6
1234 2345
1234 0123
1234 2267
1234 3401
1234 1344
1234 2468

output:

1
1
4
5
1
4

result:

ok 6 numbers

Test #2:

score: -100
Wrong Answer
time: 40ms
memory: 3664kb

input:

100000
9138 9251
0887 4577
2745 6294
6883 1197
8654 2502
7867 7941
7505 2717
1497 7726
3337 8042
2767 8782
5311 4368
9711 6229
7105 8101
3553 6673
6544 7940
8848 8920
1458 6315
4605 2931
5505 7310
5963 4765
7625 0418
4049 0136
2078 6899
3339 1080
2276 6814
4249 4182
1861 0824
8975 8926
6447 6965
226...

output:

3
6
6
9
10
7
8
7
10
9
6
8
5
9
11
5
8
7
9
4
10
8
8
6
8
7
8
6
8
5
7
7
6
8
4
10
6
5
8
7
8
7
9
7
8
7
7
12
7
6
7
11
10
12
7
5
8
7
7
8
9
9
5
7
6
8
8
6
7
9
10
7
11
8
6
7
8
6
8
6
8
7
8
8
7
8
9
7
6
5
7
6
6
5
7
5
11
7
10
7
7
11
9
10
5
5
11
10
7
3
9
6
7
11
8
6
6
10
10
5
7
6
9
11
7
11
6
10
7
6
11
7
13
6
7
5
10
...

result:

wrong answer 4th numbers differ - expected: '8', found: '9'