QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#233205#6621. Luggage LockicreiysWA 0ms3600kbC++201.5kb2023-10-31 15:07:572023-10-31 15:07:58

Judging History

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

  • [2023-10-31 15:07:58]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3600kb
  • [2023-10-31 15:07:57]
  • 提交

answer

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

int ans;
int a[10];


void dfs(int pos,int val,int cnt)
{
    if(pos == 5){
        ans = min(ans,cnt);
        return;
    }
    int x = a[pos];
    if(x<0)x+=10;
    if(x<0||x>=10){
        while(1){
            ans=ans+1;
            ans=ans-1;
            
        }
    }
    if(x == 0){
        dfs(pos+1,0,cnt);
    }
    else{
        //逆时针转
        int tmp_x = -x;
        if(val<=tmp_x){
            dfs(pos+1,tmp_x,cnt);
        }
        else{
            if(val<0){
                int tmp = val - tmp_x;
                dfs(pos+1,tmp_x,cnt+tmp);
            }
            else{
                int tmp = x;
                dfs(pos+1,tmp_x,cnt+tmp);
            }
        }
        //顺时针转
        tmp_x = 10 - x;
        if(val >= tmp_x){
            dfs(pos+1,tmp_x,cnt);
        }
        else{
            if(val>0){
                int tmp = tmp_x - val;
                dfs(pos+1,tmp_x,cnt+tmp);
            }
            else{
                int tmp = tmp_x;
                dfs(pos+1,tmp_x,cnt+tmp);
            }
        }
    }
}
void solve()
{
    string s1,s2;
    cin>>s1>>s2;
    cout<<"*"<<s1<<" "<<s2<<endl;
    for(int i=1;i<=4;i++){
        a[i] = s2[i-1] - s1[i-1];
    }
    ans = 100;
    dfs(1,0,0);
    cout<<ans<<"\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t  = 1;
    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

详细

Test #1:

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

input:

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

output:

*1234 2345
1
*1234 0123
1
*1234 2267
4
*1234 3401
5
*1234 1344
1
*1234 2468
4

result:

wrong output format Expected integer, but "*1234" found