# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
144244 |
2019-08-16T11:37:12 Z |
Milki |
Board (CEOI13_board) |
C++14 |
|
5 ms |
1204 KB |
#include<bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<
#define sz(x) ((int) x.size())
#define pb(x) push_back(x)
#define TRACE(x) cerr << #x << " = " << x << endl
typedef long long ll;
typedef pair<int, int> point;
vector <int> a, b;
string sa, sb;
const int off = 1 << 17;
void update(string &s, vector <int> &v){
for(auto it : s){
if(it == '1')
v.pb(0);
else if(it == '2')
v.pb(1);
else if(it == 'L')
v.back() --;
else if(it == 'R')
v.back() ++;
else{
int x = v.back();
v.pop_back();
if(x >= 0){
v.back() += x / 2;
}
else{
v.back() += x / 2;
x -= x / 2 * 2;
if(x < 0){
v.back() --;
}
}
}
}
}
void prop(vector <int> &v){
for(int i = sz(v) - 1; i > 0; --i){
int x = v[i];
if(x >= 0){
v[i - 1] += v[i] / 2;
v[i] %= 2;
}
else{
v[i - 1] += v[i] / 2;
v[i] -= v[i] / 2 * 2;
if(v[i] < 0){
v[i - 1] --;
v[i] += 2;
}
}
}
}
int main(){
ios_base::sync_with_stdio(false); cin.tie(0);
cin >> sa >> sb;
update(sa, a);
update(sb, b);
prop(a); prop(b);
ll tmp = sz(a) + sz(b), dist = 0;
ll sol = tmp;
REP(i, min(sz(a), sz(b))){
dist <<= 1;
dist += abs(a[i] - b[i]);
tmp -= 2;
sol = min(sol, tmp + dist);
if(dist > 1e13)
break;
}
cout << sol;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
504 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
504 KB |
Output is correct |
2 |
Incorrect |
5 ms |
632 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1140 KB |
Output is correct |
2 |
Incorrect |
4 ms |
1204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
1140 KB |
Output is correct |
2 |
Incorrect |
4 ms |
1204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
1140 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |