Kickdown
解决方法:上板不动,下板向左移;上板不动,下板向右移。
AC代码:
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <bitset>
#include <set>
#include <utility>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define inf 0x3f3f3f3f
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define lep(i,l,r) for(int i=l;i>=r;i--)
#define ms(arr) memset(arr,0,sizeof(arr))
//priority_queue<int,vector<int> ,greater<int> >q;
const int maxn = (int)1e5 + 5;
const ll mod = 1e9+7;
char s1[maxn];
char s2[maxn];
char s3[maxn];
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
#endif
//freopen("out.txt", "w", stdout);
while(scanf("%s",s1)!=EOF)
{
scanf("%s",s2);
int len1=strlen(s1);
int len2=strlen(s2);
if(len1<len2)
{
strcpy(s3,s1);
strcpy(s1,s2);
strcpy(s2,s3);
int t;
t=len1;
len1=len2;
len2=t;
}
/*printf("%s\n%s\n",s1,s2);*/
int k1,k2=0,id1,id2,nape=0;
bool ju=false;
for(int i=0;i<len1;i++)
{
k1=i;
id1=s1[k1]-'0';
id2=s2[k2]-'0';
while(id1+id2<=3)
{
nape++;
k1++;
k2++;
if(k1==len1||k2==len2)
{
ju=true;
break;
}
id1=s1[k1]-'0';
id2=s2[k2]-'0';
}
if(ju)
break;
else
{
k2=0;
nape=0;
}
}
k2=len2-1;
int nape1=0,ju1=false;
for(int i=len1-1;i>=0;i--)
{
k1=i;
id1=s1[k1]-'0';
id2=s2[k2]-'0';
while(id1+id2<=3)
{
nape1++;
k1--;
k2--;
if(k1==-1||k2==-1)
{
ju1=true;
break;
}
id1=s1[k1]-'0';
id2=s2[k2]-'0';
}
if(ju1)
break;
else
{
k2=len2-1;
nape1=0;
}
}
nape=max(nape,nape1);
printf("%d\n",len1+len2-nape);
}
return 0;
}