답안 #11365

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
11365 2014-11-21T14:05:35 Z gs14004 게임판 (CEOI13_board) C++
10 / 100
4 ms 2084 KB
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <algorithm>
using namespace std;

struct big{
    vector<int> s;
    void i(){
        s.push_back(1);
    }
    void one(){
        s.push_back(0);
    }
    void two(){
        s.push_back(1);
    }
    void l(){
        s.back()--;
    }
    void r(){
        s.back()++;
    }
    void u(){
        int r = s.back();
        s.pop_back();
        if(r >= 0){
            s.back() += r/2;
            r %= 2;
        }
        else{
            s.back() -= r/2 * 2;
            r -= r/2 * 2;
            while(r < 0) s.back()--, r += 2;
        }
    }
    int ret(){
        if(s.empty()) return -1;
        int r = s.back();
        s.pop_back();
        if(r >= 0){
            s.back() += r/2;
            r %= 2;
        }
        else{
            s.back() -= r/2 * 2;
            r -= r/2 * 2;
            while(r < 0) s.back()--, r += 2;
        }
        return r;
    }
}x,y;

int main(){
    char str1[100005], str2[100005];
    scanf("%s %s",str1,str2);
    x.i();
    y.i();
    for (int i=0; str1[i]; i++) {
        if(str1[i] == '1') x.one();
        if(str1[i] == '2') x.two();
        if(str1[i] == 'L') x.l();
        if(str1[i] == 'R') x.r();
        if(str1[i] == 'U') x.u();
    }
    for (int i=0; str2[i]; i++) {
        if(str2[i] == '1') y.one();
        if(str2[i] == '2') y.two();
        if(str2[i] == 'L') y.l();
        if(str2[i] == 'R') y.r();
        if(str2[i] == 'U') y.u();
    }
    vector<char> r1,r2;
    while (1) {
        int r = x.ret();
        if(r == -1) break;
        r1.push_back(r);
    }
    while (1) {
        int r = y.ret();
        if(r == -1) break;
        r2.push_back(r);
    }
    reverse(r1.begin(),r1.end());
    reverse(r2.begin(),r2.end());
    int res = (int)(r1.size() + r2.size());
    int piv = 0;
    while (piv < r1.size() && piv < r2.size() && r1[piv] == r2[piv]) {
        res-=2;
        piv++;
    }
    int rr = res;
    int dist = 0;
    while (piv < r1.size() && piv < r2.size()) {
        dist <<= 1;
        dist += r2[piv] - r1[piv];
        res -= 2;
        piv++;
        rr = min(rr,res + abs(dist));
        if(abs(dist) > 1000000) break;
    }
    printf("%d",rr);
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 1304 KB open (syscall #2) was called by the program (disallowed syscall)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 1304 KB open (syscall #2) was called by the program (disallowed syscall)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 1308 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 1308 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1308 KB Output is correct
2 Correct 0 ms 1304 KB Output is correct
3 Correct 0 ms 1308 KB Output is correct
4 Correct 0 ms 1312 KB Output is correct
5 Correct 0 ms 1308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 1312 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1312 KB Output is correct
2 Incorrect 4 ms 1312 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2080 KB Output is correct
2 Incorrect 4 ms 2076 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 2080 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 2076 KB Output is correct
2 Correct 4 ms 2084 KB Output is correct
3 Incorrect 0 ms 2084 KB Output isn't correct
4 Halted 0 ms 0 KB -