# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
54078 |
2018-07-02T09:46:45 Z |
okaybody10 |
Board (CEOI13_board) |
C++11 |
|
11 ms |
2212 KB |
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int MAX = 0x7fffffff;
ll node1,node2;
int stair1,stair2;
int main()
{
node1=node2=1;
string a,b; cin>>a>>b;
int v=a.size();
for(int i=0;i<v;i++)
{
if(a[i]=='1') stair1++,node1=2*(node1-1)+1;
else if(a[i]=='2') stair1++,node1=2*(node1-1)+2;
else if(a[i]=='U') stair1--,node1=(node1+1)/2;
else if(a[i]=='L') node1--;
else node1++;
}
int v1=b.size();
for(int i=0;i<v1;i++)
{
if(b[i]=='1') stair2++,node2=2*(node2-1)+1;
else if(b[i]=='2') stair2++,node2=2*(node2-1)+2;
else if(b[i]=='U') stair2--,node2=(node2+1)/2;
else if(b[i]=='L') node2--;
else node2++;
}
int cnt=0;
//printf("%d %lld %d %lld\n",stair1,node1,stair2,node2);
if(stair2<stair1) swap(stair1,stair2),swap(node1,node2);
ll base=stair2-stair1;
while(stair2!=stair1)
{
stair2--,node2=(node2+1)/2;
}
ll ans=MAX;
while(stair1)
{
ans=min(ans,abs(node2-node1)+2*cnt);
node1=(node1+1)/2,node2=(node2+1)/2;
cnt++;
stair1--;
}
return !printf("%lld",base+ans);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
360 KB |
Output is correct |
3 |
Correct |
2 ms |
636 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
972 KB |
Output is correct |
2 |
Correct |
3 ms |
972 KB |
Output is correct |
3 |
Correct |
8 ms |
1116 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1116 KB |
Output is correct |
2 |
Correct |
2 ms |
1116 KB |
Output is correct |
3 |
Correct |
2 ms |
1116 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1116 KB |
Output is correct |
2 |
Correct |
10 ms |
1484 KB |
Output is correct |
3 |
Correct |
8 ms |
1484 KB |
Output is correct |
4 |
Correct |
2 ms |
1484 KB |
Output is correct |
5 |
Correct |
2 ms |
1484 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
1484 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
1484 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
1484 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
1832 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
11 ms |
2020 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
2212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |