# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
32345 |
2017-10-09T20:00:28 Z |
imaxblue |
Board (CEOI13_board) |
C++14 |
|
16 ms |
2628 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define pii pair<int, int>
#define p3i pair<pii, int>
#define pll pair<ll, ll>
#define p3l pair<pll, ll>
#define lseg L, (L+R)/2, N*2+1
#define rseg (L+R)/2+1, R, N*2+2
#define ub upper_bound
#define lb lower_bound
#define pq priority_queue
#define MN 1000000007
#define fox(k, x) for (int k=0; k<x; ++k)
#define fox1(k, x) for (int k=1; k<=x; ++k)
#define foxr(k, x) for (int k=x-1; k>=0; --k)
#define fox1r(k, x) for (int k=x; k>0; --k)
#define ms multiset
#define flood(x) memset(x, 0x3f3f3f3f, sizeof x)
#define drain(x) memset(x, 0, sizeof x)
#define rng() (rand() >> 3)*rand()
set<int> pre;
string s, t;
bool type;
int p, x;
void flip(int p){
if (pre.count(p)) pre.erase(p);
else pre.insert(p);
}
string con(string S){
type=0; p=0; pre.clear();
fox(l, S.size()){
if (S[l]=='1' && type){
type=0;
pre.insert(p);
}
if (S[l]=='2' && !type){
type=1;
pre.insert(p);
}
if (S[l]=='1' || S[l]=='2') p++;
if (S[l]=='U'){
--p;
if (pre.count(p)){
type=!type;
pre.erase(p);
}
}
if (S[l]=='L'){
if (type){
flip(p-1);
} else {
x=*--pre.end();
flip(--x);
}
type=!type;
}
if (S[l]=='R'){
if (!type){
flip(p-1);
} else {
x=*--pre.end();
flip(--x);
}
type=!type;
}
}
type=0;
S="";
//cout << p << endl;
fox(l, p){
if (pre.count(l)) type=!type;
S+=char(type+'0');
}
return S;
}
int main(){
cin.sync_with_stdio(0);
cin.tie(0);
cin >> s;
s=con(s);
cin >> t;
t=con(t);
//cout << s << ' ' << endl << t << endl;
ll a=0, b=0;
int ans=(1 << 30);
fox(l, min(s.size(), t.size())){
a=a*2+s[l]-'0';
b=b*2+t[l]-'0';
if (abs(b-a)>400000) break;
//cout << a << ' ' << b << endl;
ans=min(ans, int(abs(a-b)+s.size()+t.size()-l*2-2));
}
cout << ans << endl;
return 0;
}
Compilation message
board.cpp: In function 'std::__cxx11::string con(std::__cxx11::string)':
board.cpp:18:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
#define fox(k, x) for (int k=0; k<x; ++k)
^
board.cpp:37:5: note: in expansion of macro 'fox'
fox(l, S.size()){
^
board.cpp: In function 'int main()':
board.cpp:18:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
#define fox(k, x) for (int k=0; k<x; ++k)
^
board.cpp:92:5: note: in expansion of macro 'fox'
fox(l, min(s.size(), t.size())){
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2180 KB |
Output is correct |
2 |
Correct |
0 ms |
2180 KB |
Output is correct |
3 |
Correct |
0 ms |
2180 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
2476 KB |
Output is correct |
2 |
Correct |
0 ms |
2180 KB |
Output is correct |
3 |
Correct |
6 ms |
2452 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2180 KB |
Output is correct |
2 |
Correct |
0 ms |
2180 KB |
Output is correct |
3 |
Correct |
0 ms |
2180 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2312 KB |
Output is correct |
2 |
Correct |
13 ms |
2532 KB |
Output is correct |
3 |
Correct |
3 ms |
2332 KB |
Output is correct |
4 |
Correct |
0 ms |
2180 KB |
Output is correct |
5 |
Correct |
0 ms |
2180 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2180 KB |
Output is correct |
2 |
Correct |
0 ms |
2180 KB |
Output is correct |
3 |
Correct |
0 ms |
2180 KB |
Output is correct |
4 |
Correct |
0 ms |
2180 KB |
Output is correct |
5 |
Correct |
0 ms |
2180 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2180 KB |
Output is correct |
2 |
Correct |
0 ms |
2180 KB |
Output is correct |
3 |
Correct |
0 ms |
2180 KB |
Output is correct |
4 |
Correct |
0 ms |
2180 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2332 KB |
Output is correct |
2 |
Correct |
16 ms |
2532 KB |
Output is correct |
3 |
Correct |
9 ms |
2464 KB |
Output is correct |
4 |
Correct |
0 ms |
2180 KB |
Output is correct |
5 |
Correct |
0 ms |
2180 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
2628 KB |
Output is correct |
2 |
Correct |
6 ms |
2524 KB |
Output is correct |
3 |
Correct |
0 ms |
2180 KB |
Output is correct |
4 |
Correct |
0 ms |
2180 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
2600 KB |
Output is correct |
2 |
Correct |
16 ms |
2604 KB |
Output is correct |
3 |
Correct |
0 ms |
2180 KB |
Output is correct |
4 |
Correct |
0 ms |
2180 KB |
Output is correct |
5 |
Correct |
9 ms |
2532 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
2464 KB |
Output is correct |
2 |
Correct |
9 ms |
2608 KB |
Output is correct |
3 |
Correct |
3 ms |
2332 KB |
Output is correct |
4 |
Correct |
0 ms |
2180 KB |
Output is correct |
5 |
Correct |
0 ms |
2180 KB |
Output is correct |
6 |
Correct |
3 ms |
2532 KB |
Output is correct |