답안 #257027

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
257027 2020-08-03T14:13:16 Z doowey 게임판 (CEOI13_board) C++14
10 / 100
200 ms 1444 KB
#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;
}

int main(){
    fastIO;
    string a, b;
    cin >> a >> b;
    vector<int> p = gen(a), q = gen(b);
    int ans = 0;
    while(p.size() > q.size()){
        ans ++ ;
        p.pop_back();
    }
    int cq;
    for(int t = 0; t < p.size(); t ++ ){
        if(p[t] != q[t]){
            cq = t + 1;
            while(cq < p.size()){
                if(p[cq] != p[t]) cq ++ ;
                else break;
            }
            while(p.size() > cq){
                ans ++ ;
                p.pop_back();
            }
            ans ++ ;
            for(int j = t; j < cq; j ++ ){
                p[j] ^= 1;
            }
        }
    }
    ans += q.size() - p.size();
    cout << ans << "\n";
    return 0;
}

Compilation message

board.cpp: In function 'int main()':
board.cpp:62:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int t = 0; t < p.size(); t ++ ){
                    ~~^~~~~~~~~~
board.cpp:65:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             while(cq < p.size()){
                   ~~~^~~~~~~~~~
board.cpp:69:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             while(p.size() > cq){
                   ~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Incorrect 1 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 768 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Incorrect 2 ms 768 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Incorrect 0 ms 392 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 512 KB Output is correct
2 Incorrect 4 ms 896 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Incorrect 1 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 512 KB Output is correct
2 Incorrect 3 ms 768 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1075 ms 1400 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1083 ms 1444 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1093 ms 1272 KB Time limit exceeded
2 Halted 0 ms 0 KB -