1588 - Kickdown

All about problems in Volume 15. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

robin_0
New poster
Posts: 7
Joined: Tue Apr 28, 2015 9:47 am

Re: 1588 - Kickdown

Getting WA

Any critical inputs ?

cksteven
New poster
Posts: 5
Joined: Wed Jul 23, 2014 9:38 am

1588 Kickdown WA

I thought this algorithm i used is correct...but i got WAs.
Could anyone help me with it or provide some inputs for test?

Code: Select all

``````#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int main(){
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif
string s1,s2;
while(cin>>s1>>s2){
if(s1.length()<s2.length()){
string t;
t=s1;
s1=s2;
s2=t;
}
//cout<<s1<<endl<<s2<<endl<<endl;
int l1=s1.length();
int l2=s2.length();
int i=0,flag=1,mini=120;
while(i<=l1+l2){
flag=1;
for(int j=0;j<l2;j++){
//cout<<l1-i+j<<":"<<j<<"//"<<endl;
if((l1-i+j>=0)&&(l1-i+j<l1)){
//cout<<s1[l1-i+j]<<"."<<s2[j]<<endl;
if(s1[l1-i+j]+s2[j]-'0'-'0'>3) flag=0;
}
}
//cout<<flag<<" "<<i<<"  "<<l1+l2-i<<"/";
if(flag){
if(i<l1) mini=min(mini,max(l1+l2-i,l1));
else mini=min(mini,i);
}
i++;
}
cout<<mini<<endl;

}
return 0;
}``````