답안 #478094

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
478094 2021-10-05T14:59:47 Z FatihSolak Nizovi (COI14_nizovi) C++17
90 / 100
223 ms 200 KB
#include <bits/stdc++.h>
using namespace std;
int ask(int x,int y){
    cout << "cmp " << x << " " << y << endl;
    int ret;
    cin >> ret;
    return ret;
}
void revers(int l,int r){
    cout << "reverse " << l << " " << r << endl;
}
int main(){
    int a,b;
    cin >> a >> b;
    int pos = 1;
    for(int i=1;i<=a && pos < a  + b;i++){
        int l = pos + a - i + 1, r = a+b;
        int cnt = -l;
        if(ask(pos,l) != 1){
            pos++;
            continue;
        }
        while(l < r){
            int m = (l + r + 1)/2;
            if(ask(m,pos) == 1){
                r = m-1;
            }
            else l = m;
        }
        cnt += l;
        revers(pos,l);
        revers(pos,pos+cnt);
        revers(pos+cnt+1,l);
        pos += cnt + 2;
    }
    cout << "end" << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 2 ms 200 KB Output is correct
3 Correct 2 ms 200 KB Output is correct
4 Correct 28 ms 200 KB Output is correct
5 Runtime error 29 ms 200 KB Execution killed with signal 13
6 Correct 27 ms 200 KB Output is correct
7 Correct 167 ms 200 KB Output is correct
8 Correct 188 ms 200 KB Output is correct
9 Correct 223 ms 200 KB Output is correct
10 Correct 221 ms 200 KB Output is correct