# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
257065 | doowey | 게임판 (CEOI13_board) | C++14 | 1094 ms | 1512 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
vector<int> gen(string t){
vector<int> res = {1};
for(char x : t){
if(x == '1') res.push_back(0);
else if(x == '2') res.push_back(1);
else if(x == 'U'){
res.pop_back();
}
else if(x == 'L'){
int id = res.size() - 1;
while(id >= 0){
if(res[id] == 0){
res[id] ^= 1;
}
else{
res[id] ^= 1;
break;
}
id -- ;
}
}
else{
int id = res.size() - 1;
while(id >= 0){
if(res[id] == 0){
res[id] ^= 1;
break;
}
else{
res[id] ^= 1;
}
id -- ;
}
}
}
return res;
}
const ll MX = (int)1e9 + 7;
const int N = (int)2e5 + 10;
int main(){
fastIO;
string a, b;
cin >> a >> b;
vector<int> p = gen(a), q = gen(b);
if(p.size() > q.size())
swap(p,q);
ll low = (int)p.size() - 1 + (int)q.size() - 1;
ll dif = 0;
int side = -1;
for(int com = 0; com < min(p.size(), q.size()); com ++ ){
dif *= 2ll;
if(dif >= MX) break;
if(p[com] != q[com]){
if(side == -1){
if(p[com] == 1) side = 0;
else side = 1;
}
if(p[com] == 1){
if(side == 0) dif ++ ;
else dif -- ;
}
else{
if(side == 1) dif ++ ;
else dif -- ;
}
}
low = min(low, dif + (ll)p.size() - (com + 1) + (ll)q.size() - (com + 1));
}
cout << low << "\n";
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |