Submission #931102

#TimeUsernameProblemLanguageResultExecution timeMemory
931102batsukh2006Board (CEOI13_board)C++17
40 / 100
2 ms976 KiB
#include<iostream> #include<stdio.h> #include<math.h> #include<map> #include<string> #include<algorithm> #include<vector> #include<string.h> #include<utility> #include<set> #include<cmath> #include<queue> #include<deque> #include<functional> #include<stack> #include<limits.h> #include<iomanip> #include<unordered_map> #include<numeric> #include<tuple> #include<bitset> using namespace std; #define MOD 1000000007 #define int long long #define endl '\n' int log(int x) { int sum=0; while(x>1){ sum++; x/=2; } return sum; } void solve(){ string a,b; cin>>a>>b; int f=1,s=1; for(int i=0; i<a.size(); i++){ if(a[i]=='1') f=f*2; if(a[i]=='2') f=f*2+1; if(a[i]=='U') f=f/2; if(a[i]=='L') f=f-1; if(a[i]=='R') f=f+1; } for(int i=0; i<b.size(); i++){ if(b[i]=='1') s=s*2; if(b[i]=='2') s=s*2+1; if(b[i]=='U') s=s/2; if(b[i]=='L') s=s-1; if(b[i]=='R') s=s+1; } if(log(f)>log(s)) swap(f,s); int diff=log(s)-log(f); int sum=diff; while(diff--) s/=2; int ans=sum+abs(f-s); int cur=log(f); while(cur--){ sum+=2; f/=2; s/=2; ans=min(ans,sum+abs(f-s)); } cout<<ans; } signed main(){ // freopen("file.in", "r", stdin); // freopen("file.out", "w", stdout); ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int T=1; // cin>>T; while(T--){ solve(); cout<<endl; } return 0; }

Compilation message (stderr)

board.cpp: In function 'void solve()':
board.cpp:38:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     for(int i=0; i<a.size(); i++){
      |                  ~^~~~~~~~~
board.cpp:45:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |     for(int i=0; i<b.size(); i++){
      |                  ~^~~~~~~~~
#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...