답안 #478167

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
478167 2021-10-06T06:35:35 Z FatihSolak Nizovi (COI14_nizovi) C++17
100 / 100
222 ms 220 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 rev(int l,int r){
    if(l >= r)return;
    cout << "reverse " << l << " " << r << endl;
}
int main(){
    int a,b;
    cin >> a >> b;
    int pos = 1;
    int cntb = b;
    for(int i=1;i<=a && cntb;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;
        cntb -= cnt + 1;
        rev(pos,l);
        rev(pos,pos+cnt);
        rev(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 220 KB Output is correct
4 Correct 32 ms 200 KB Output is correct
5 Correct 28 ms 200 KB Output is correct
6 Correct 34 ms 200 KB Output is correct
7 Correct 156 ms 200 KB Output is correct
8 Correct 222 ms 200 KB Output is correct
9 Correct 190 ms 200 KB Output is correct
10 Correct 193 ms 200 KB Output is correct