Submission #930202

#TimeUsernameProblemLanguageResultExecution timeMemory
930202ezzzayBoard (CEOI13_board)C++14
40 / 100
15 ms2132 KiB
#include<bits/stdc++.h> using namespace std; #define ff first #define ss second #define int long long map<int,int>dist; string a,b; signed main(){ cin>>a; int x=1; int y=1; int lvl=1; dist[1]=1; for(auto c:a){ if(c=='1'){ x*=2; lvl++; } else if(c=='2'){ x=x*2+1; lvl++; } else if(c=='U'){ x=x/2; lvl--; } else if(c=='L'){ x--; } else{ x++; } dist[x]=lvl; } lvl=1; cin>>a; for(auto c:a){ if(c=='1'){ y*=2; lvl++; } else if(c=='2'){ y=y*2+1; lvl++; } else if(c=='U'){ y=y/2; lvl--; } else if(c=='L'){ y--; } else{ y++; } dist[y]=lvl; } if(dist[y]>dist[x]){ swap(y,x); } int k=0; int p=dist[x]; while(dist[x]>dist[y]){ x=x/2; dist[x]= --p; k++; } int ans=k+abs(x-y); p=dist[x]; while(p>1){ x=x/2; y=y/2; p--; k+=2; ans=min(ans,k+abs(x-y)); } cout<<ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...