QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#545903 | #6621. Luggage Lock | Albert711 | WA | 112ms | 3752kb | C++14 | 1.3kb | 2024-09-03 18:05:17 | 2024-09-03 18:05:18 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
const int mod=1e9+7;
const int N=2e5+5;
void solve(){
string sa,sb;
cin>>sa>>sb;
vector<int> a(5),b(5);
for(int i=0;i<4;i++){
a[i]=sa[i]-'0';
}
for(int i=0;i<4;i++){
b[i]=sb[i]-'0';
}
int ans=2e9;
vector<pair<int,int>> ran={{0,3},{1,3},{0,2},{0,1},{2,3},{1,2},{2,2},{0,0},{3,3},{1,1}};
for(int i=0;i<16;i++){
vector<int> mg(5);
for(int j=0;j<4;j++){
if((i>>j)&1){
mg[j]=(b[j]-a[j]+10)%10;
}else{
mg[j]=(a[j]-b[j]+10)%10;
}
}
int cnt=0;
for(auto now:ran){
int minn=1e9;
int c1=0;
for(int j=now.first;j<=now.second;j++){
minn=min(minn,mg[j]);
c1+=((i>>j)&1);
}
if(c1==0||c1==now.second-now.first+1){
for(int j=now.first;j<=now.second;j++){
mg[j]-=minn;
}
cnt+=minn;
}
}
ans=min(ans,cnt);
}
cout<<ans<<endl;
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);cout.tie(nullptr);
int T=1;
cin>>T;
while(T--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3532kb
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: 112ms
memory: 3752kb
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 8 9 7 6 7 10 9 6 8 5 4 8 5 8 7 9 4 8 8 8 6 8 5 7 5 7 5 7 7 6 8 4 10 6 5 6 7 7 7 4 7 8 6 5 9 7 6 7 11 10 10 7 5 6 5 7 6 7 9 5 5 6 6 8 5 7 9 10 6 11 5 6 7 6 6 8 6 8 7 7 8 7 8 6 7 6 5 5 6 6 5 7 5 9 6 7 7 7 9 6 9 5 5 8 10 7 3 5 6 7 9 8 6 6 7 10 5 5 6 9 8 6 8 6 5 7 6 11 5 9 6 7 5 10 7 5 8 9 8 7 7 7...
result:
wrong answer 73rd numbers differ - expected: '10', found: '11'