QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#782074 | #6621. Luggage Lock | k4sum1 | WA | 0ms | 3732kb | C++17 | 1.6kb | 2024-11-25 18:47:16 | 2024-11-25 18:47:17 |
Judging History
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[(y1-x1+10)%10][(y2-x2+10)%10][(y3-x3+10)%10][(y4-x4+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);
// if(a1==2&&a2==0&&a3==1&&a4==1)
// {
// cout<<a1+i<<a2+j<<a3+k<<a4+l<<' ';
// cout<<a[(a1+i+20)%10][(a2+j+20)%10][(a3+k+20)%10][(a4+l+20)%10]<<'\n';
// }
}
}
}
}
}
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();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3732kb
input:
6 1234 2345 1234 0123 1234 2267 1234 3401 1234 1344 1234 2468
output:
1 1 4 6 1 4
result:
wrong answer 4th numbers differ - expected: '5', found: '6'