# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
63691 | 2018-08-02T13:49:44 Z | bazsi700 | Board (CEOI13_board) | C++14 | 200 ms | 1320 KB |
#include <bits/stdc++.h> using namespace std; #define MOD 1000000007 #define ll long long int #define vi vector<int> #define vii vector< vector<int> > #define PI 3.1415926535897932384626433832795 #define INF 9223372036854775807LL //15:20 bool node1[100005]; bool node2[100005]; int lev1,lev2; int main() { ios::sync_with_stdio(false); cin.tie(NULL); string a; string b; cin >> a >> b; //cout << a << " " << b << endl; node1[0] = node2[0] = 1; lev1 = lev2 = 0; for(int i = 0; i < a.length(); i++) { if(a.at(i) == '1') { lev1++; } else if(a.at(i) == '2') { lev1++; node1[lev1] = true; } else if(a.at(i) == 'L') { for(int j = lev1; j >= 0; j--) { if(node1[j]) { node1[j] = false; break; } else { node1[j] = true; } } } else if(a.at(i) == 'R') { for(int j = lev1; j >= 0; j--) { if(!node1[j]) { node1[j] = true; break; } else { node1[j] = false; } } } else { node1[lev1] = false; lev1--; } } for(int i = 0; i < b.length(); i++) { //cout <<"a" << node2 << " "; if(b.at(i) == '1') { lev2++; } else if(b.at(i) == '2') { lev2++; node2[lev2] = true; } else if(b.at(i) == 'L') { for(int j = lev2; j >= 0; j--) { if(node2[j]) { node2[j] = false; break; } else { node2[j] = true; } } } else if(b.at(i) == 'R') { for(int j = lev2; j >= 0; j--) { if(!node2[j]) { node2[j] = true; break; } else { node2[j] = false; } } } else { node2[lev2] = false; lev2--; } } if(lev1 > lev2) { swap(lev1,lev2); swap(node1,node2); } int wasdif = lev2-lev1; for(int i = 0; i < lev2-lev1; i++) { lev2--; } ll ans = INF; ll nod1 = 0; ll nod2 = 0; int waslev = lev1; for(int goesupmore = 0; goesupmore < waslev; goesupmore++) { if(lev1-goesupmore <= 20) { if(nod1 == 0) { for(int i = 0; i <= lev1; i++) { nod1*=2; if(node1[i]) { nod1++; } nod2*=2; if(node2[i]) { nod2++; } } } ans = min(ans,wasdif+goesupmore*2+abs(nod1-nod2)); nod1/=2; nod2/=2; } else { //cout << node1 << " " << node2 << " " << lev1-lev2<< " " << goesupmore*2<< " " << abs(node1-node2) << endl; lev1--; lev2--; } } ans = min(ans,wasdif+waslev*2+abs(nod1-nod2)); //cout << node2 << endl; cout << ans; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 364 KB | Output is correct |
3 | Correct | 3 ms | 436 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 728 KB | Output is correct |
2 | Correct | 4 ms | 728 KB | Output is correct |
3 | Correct | 5 ms | 932 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 932 KB | Output is correct |
2 | Correct | 2 ms | 932 KB | Output is correct |
3 | Correct | 2 ms | 932 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 932 KB | Output is correct |
2 | Correct | 5 ms | 932 KB | Output is correct |
3 | Incorrect | 4 ms | 932 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 932 KB | Output is correct |
2 | Correct | 2 ms | 932 KB | Output is correct |
3 | Incorrect | 2 ms | 932 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 932 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 932 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1059 ms | 1320 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1078 ms | 1320 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1065 ms | 1320 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |