답안 #55635

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
55635 2018-07-08T10:11:56 Z leehosu01 게임판 (CEOI13_board) C++17
0 / 100
200 ms 852 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
class IB{
public:
    bitset<101111>NB;
    int DE;
    IB(){DE=0;NB.reset();}
    void operator<<(int n){for(;n--;DE++)NB.reset(DE);}
    void operator>>(int n){for(;n--;DE--)NB.reset(DE);}
    void operator++()
    {
        int i;
        for(i=DE-1;i>=0;i--)
            if(NB.test(i))
                NB.reset(i);
            else break;
        if(i==-1)NB.set(0),DE++;
        else NB.set(i);
    }
    void operator--()
    {
        int i;
        for(i=DE-1;i>=0;i--)
            if(!NB.test(i))
                NB.set(i);
            else break;
        if(i==-1)NB.set(DE),DE++;
        else NB.reset(i);
    }
    bool operator< (const IB&X)const
    {
        for(int i=0;i<DE-X.DE;i++)
            if(NB.test(i))return 0;
        for(int i=0;i<X.DE;i++)
            if(NB.test(DE-X.DE+i)!=X.NB.test(i))
                return X.NB.test(i);
        return 0;
    }
}tr[2];
ll mi=1<<30;
void pro(int l)
{
    ll T=0;
    for(int i=0;i<l&&T<mi;i++)
    {
        mi=min(mi,tr[0].DE+tr[1].DE-i*2+T);
        T<<=1;
        T+=(ll)tr[1].NB.test(i)-tr[0].NB.test(i);
    }
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    string S;
    for(int i=0;i<=1;i++)
    {
        cin>>S;
        for(auto&I:S)
        {
            if(I=='1')tr[i]<<1;
            else if(I=='2')tr[i]<<1,++tr[i];
            else if(I=='U')tr[i]>>1;
            else if(I=='L')--tr[i];
            else if(I=='R')++tr[i];
        }
    }
    int i;
    if(tr[1].DE<tr[0].DE)swap(tr[0],tr[1]);
    if(tr[1]<tr[0])swap(tr[0],tr[1]);
    pro(tr[0].DE);
    cout<<mi;
}

Compilation message

board.cpp: In function 'int main()':
board.cpp:69:9: warning: unused variable 'i' [-Wunused-variable]
     int i;
         ^
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Incorrect 3 ms 412 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 684 KB Output is correct
2 Incorrect 3 ms 684 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 684 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 684 KB Output is correct
2 Correct 6 ms 684 KB Output is correct
3 Incorrect 5 ms 684 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 684 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 684 KB Output is correct
2 Correct 3 ms 684 KB Output is correct
3 Incorrect 2 ms 684 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 724 KB Output is correct
2 Correct 7 ms 852 KB Output is correct
3 Incorrect 4 ms 852 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1053 ms 852 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1086 ms 852 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1068 ms 852 KB Time limit exceeded
2 Halted 0 ms 0 KB -