답안 #835009

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
835009 2023-08-23T05:35:49 Z vjudge1 Zagonetka (COI18_zagonetka) C++17
9 / 100
6 ms 208 KB
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
using namespace std;
int main() {
    int n, ans;
    vector<int> p;
    cin >> n;
    p.resize(n+1);
    for(int i=1; i<=n; i++) {
        cin >> p[i];
    }
    vector<int>small,big,v;
    for(int i=1; i<=n; i++) v.push_back(i);

    if(n <= 6) {
    cout << "query ";
    for(int i=0; i<v.size(); i++) {
        cout << v[i] << " ";
    }
    cout << endl;
    cin >> ans;
    if(ans==1) {
        if(small.empty()) {
            small = v;
        } else {
            small = min(small, v);
        }
        if(big.empty()) {
            big = v;
        } else {
            big = max(big, v);
        }
    }
    while(next_permutation(v.begin(), v.end())) {
        cout << "query ";
        for(int i=0; i<v.size(); i++) {
            cout << v[i] << " ";
        }
        cout << endl;
        cin >> ans;
        if(ans==1) {
            if(small.empty()) {
                small = v;
            } else {
                small = min(small, v);
            }
            if(big.empty()) {
                big = v;
            } else {
                big = max(big, v);
            }
        }
    }
    cout << "end" << endl;
    for(int i=0; i<small.size(); i++) cout << small[i] << " ";
    cout << endl;
    for(int i=0; i<big.size(); i++) cout << big[i] << " ";
    cout << endl;
    return 0;
    }
    pair<int,int>pil;
    pil.fi = -1;
    pil.se = -1;
    for(int i=1; i<=n-2; i++) {
        cout << "query ";
        swap(p[i], p[i+1]);
        for(int j=1; j<=n; j++) {
            cout << p[j] << " ";
        }
        cout << endl;
        cin >> ans;
        if(ans==1) {
            swap(p[i], p[i+1]);
        } else
        if(ans==0) {
            swap(p[i], p[i+1]);
            pil.fi = p[i+1];
            pil.se = p[i+2];
            p.erase(p.begin()+i+1, p.begin()+i+3);
            //p.erase(p.begin()+i+2);
            break;
        }
    }
    if(pil.fi == -1 && pil.se == -1) {
        cout << "query ";
        swap(p[3], p[2]);
        for(int i=1; i<=n; i++) {
            cout << p[i] << " ";
        }
        cout << endl;
        cin >> ans;
        if(ans==0) {
            swap(p[3], p[2]);
            pil.fi = p[1];
            pil.se = p[2];
            p.erase(p.begin()+1, p.begin()+3);
            //p.erase(p.begin()+2);
        }
    }
    sort(p.begin(), p.end());
    int mins = min(pil.fi, pil.se);
    int maks = max(pil.fi, pil.se);
    for(int i=1; i<=n; i++) {
        if(p[i]==mins-1) {
            p.insert(p.begin()+i+1, {mins, maks});
            break;
        }
    }
    //for (auto it:p) cout << it << " ";
    cout << "end" << endl;
    for(int i=1; i<=n; i++) {
        cout << p[i] << " ";
    }
    cout << endl;
    for(int i=n; i>=1; i--) {
        cout << p[i] << " ";
    }
    cout << endl;
    return 0;
}

Compilation message

zagonetka.cpp: In function 'int main()':
zagonetka.cpp:19:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     for(int i=0; i<v.size(); i++) {
      |                  ~^~~~~~~~~
zagonetka.cpp:38:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |         for(int i=0; i<v.size(); i++) {
      |                      ~^~~~~~~~~
zagonetka.cpp:57:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |     for(int i=0; i<small.size(); i++) cout << small[i] << " ";
      |                  ~^~~~~~~~~~~~~
zagonetka.cpp:59:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |     for(int i=0; i<big.size(); i++) cout << big[i] << " ";
      |                  ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 2 ms 208 KB Output is correct
5 Correct 6 ms 208 KB Output is correct
6 Correct 5 ms 208 KB Output is correct
7 Correct 4 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 208 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 208 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 208 KB Output isn't correct
2 Halted 0 ms 0 KB -