Submission #50899

# Submission time Handle Problem Language Result Execution time Memory
50899 2018-06-14T10:39:54 Z tmwilliamlin168 Board (CEOI13_board) C++14
80 / 100
200 ms 1012 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long

const int mxD=1e5, bs=25, mxBC=mxD/bs+1;
int sa, sb, ans=2*mxD, a1=0;
ll bva[mxBC], bvb[mxBC];

inline void rd(ll *bv, int &s) {
	bv[0]=1LL<<(bs-1);
	s=1;
	string ms;
	cin >> ms;
	for(char c : ms) {
		if(c=='1') {
			bv[s/bs]&=~(1LL<<(bs-1-s%bs));
			++s;
		} else if(c=='2') {
			bv[s/bs]|=1LL<<(bs-1-s%bs);
			++s;
		} else if(c=='L') {
			bv[(s-1)/bs]-=1LL<<(bs-1-(s-1)%bs);
			for(int i=(s-1)/bs; bv[i]<0; --i) {
				bv[i]+=1LL<<bs;
				--bv[i-1];
			}
		} else if(c=='R') {
			bv[(s-1)/bs]+=1LL<<(bs-1-(s-1)%bs);
			for(int i=(s-1)/bs; bv[i]>=1LL<<bs; --i) {
				bv[i]-=1LL<<bs;
				++bv[i-1];
			}
		} else
			--s;
	}
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	rd(bva, sa);
	rd(bvb, sb);
	for(int i=0; i<min(sa, sb)&&abs(a1)<=ans; ++i) {
		a1=2*a1+(bva[i/bs]>>(bs-1-i%bs)&1)-(bvb[i/bs]>>(bs-1-i%bs)&1);
		ans=min(abs(a1)+sa-i+sb-i-2, ans);
	}
	cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 380 KB Output is correct
3 Correct 2 ms 428 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 556 KB Output is correct
2 Correct 2 ms 556 KB Output is correct
3 Correct 4 ms 716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 716 KB Output is correct
2 Correct 2 ms 716 KB Output is correct
3 Correct 2 ms 716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 716 KB Output is correct
2 Correct 5 ms 768 KB Output is correct
3 Correct 3 ms 768 KB Output is correct
4 Correct 3 ms 768 KB Output is correct
5 Correct 2 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 768 KB Output is correct
2 Correct 2 ms 768 KB Output is correct
3 Correct 2 ms 768 KB Output is correct
4 Correct 2 ms 768 KB Output is correct
5 Correct 2 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 768 KB Output is correct
2 Correct 2 ms 768 KB Output is correct
3 Correct 2 ms 768 KB Output is correct
4 Correct 1 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 768 KB Output is correct
2 Correct 5 ms 804 KB Output is correct
3 Correct 4 ms 804 KB Output is correct
4 Correct 2 ms 804 KB Output is correct
5 Correct 2 ms 804 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 104 ms 1012 KB Output is correct
2 Correct 106 ms 1012 KB Output is correct
3 Correct 3 ms 1012 KB Output is correct
4 Correct 2 ms 1012 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 97 ms 1012 KB Output is correct
2 Correct 105 ms 1012 KB Output is correct
3 Correct 2 ms 1012 KB Output is correct
4 Correct 2 ms 1012 KB Output is correct
5 Execution timed out 240 ms 1012 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Correct 96 ms 1012 KB Output is correct
2 Correct 101 ms 1012 KB Output is correct
3 Correct 52 ms 1012 KB Output is correct
4 Correct 2 ms 1012 KB Output is correct
5 Correct 2 ms 1012 KB Output is correct
6 Execution timed out 243 ms 1012 KB Time limit exceeded