# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
384260 |
2021-04-01T04:11:16 Z |
ijxjdjd |
Board (CEOI13_board) |
C++17 |
|
200 ms |
876 KB |
#include <bits/stdc++.h>
#define FR(i, N) for (int i = 0; i < int(N); i++)
#define all(x) begin(x), end(x)
using namespace std;
using ll = long long;
int main() {
cin.tie(0);
cin.sync_with_stdio(0);
string A;
string B;
cin >> A >> B;
ll sA = 1;
ll sB = 1;
for (char c : A){
if (c == '1') {
sA *= 2;
}
else if (c == '2') {
sA *= 2;
sA++;
}
else if (c == 'U') {
sA /= 2;
}
else if (c == 'L') {
sA--;
}
else if (c == 'R') {
sA++;
}
}
for (char c : B){
if (c == '1') {
sB *= 2;
}
else if (c == '2') {
sB *= 2;
sB++;
}
else if (c == 'U') {
sB /= 2;
}
else if (c == 'L') {
sB--;
}
else if (c == 'R') {
sB++;
}
}
if (sA < sB) {
swap(sA, sB);
}
ll d = 0;
for (int k = 62; k >= 0; k--) {
if (sB&(1LL<<k)) {
while (sA>=(1LL<<(k+1))) {
sA>>=1;
d++;
}
break;
}
}
if (sA < sB) {
swap(sA, sB);
}
ll res = (ll)(1e18);
while (sA != sB) {
res = min(res, sA-sB+d);
sA >>= 1;
sB >>= 1;
d+=2;
}
res = min(res, sA-sB+d);
cout << res << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
748 KB |
Output is correct |
2 |
Correct |
1 ms |
512 KB |
Output is correct |
3 |
Correct |
3 ms |
748 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
492 KB |
Output is correct |
2 |
Correct |
3 ms |
768 KB |
Output is correct |
3 |
Correct |
2 ms |
620 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1083 ms |
364 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1093 ms |
492 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1087 ms |
876 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
876 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1081 ms |
876 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |