답안 #835034

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
835034 2023-08-23T06:31:13 Z vjudge1 Zagonetka (COI18_zagonetka) C++17
9 / 100
7 ms 252 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;
    int ag[1001];
    int id;
    for(int i=2; 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==0) {
            swap(p[i], p[i+1]);
            cout << "query ";
            id = i-1;
            if(id-1 >= 1) {
                swap(p[id], p[id-1]);
                for(int j=1; j<=n; j++) {
                    cout << p[j] << " ";
                }
                cout << endl;
                cin >> ans;
                if(ans==1) {
                    swap(p[id], p[id-1]);
                    pil.fi = p[id+2];
                    pil.se = p[id+3];
                    p.erase(p.begin()+id+2, p.begin()+id+4);
                    //for (auto it:p) cout << it << " ";
                } else {
                    swap(p[id], p[id-1]);
                    pil.fi = p[id];
                    pil.se = p[id+1];
                    p.erase(p.begin()+id, p.begin()+id+2);
                    //for (auto it:p) cout << it << " ";
                }
            } else 
            if(id+4 <= n) {
                swap(p[id+3], p[id+4]);
                for(int j=1; j<=n; j++) {
                    cout << p[j] << " ";
                }
                cout << endl;
                cin >> ans;
                if(ans==1) {
                    swap(p[id+3], p[id+4]);
                    pil.fi = p[id];
                    pil.se = p[id+1];
                    p.erase(p.begin()+id, p.begin()+id+2);
                    //for (auto it:p) cout << it << " ";
                } else {
                    swap(p[id+3], p[id+4]);
                    pil.fi = p[id+2];
                    pil.se = p[id+3];
                    p.erase(p.begin()+id+2, p.begin()+id+4);
                    //for (auto it:p) cout << it << " ";
                }
            }
            break;
        }
        swap(p[i], p[i+1]);
    }
    for(int i=1; i<=id; i++) {
        if(ag[i] == 0) {
        }
    }
    sort(p.begin(), p.end());
    //debug
    //cout << "pas " << pil.fi << " " << pil.se << endl;
    int mins = min(pil.fi, pil.se);
    int maks = max(pil.fi, pil.se);
    if(mins < p[1] || maks > p[p.size()-1]) {
        cout << "end" << endl;
        if(mins < p[1]) {
           cout << mins << " " << maks << " "; 
        }
        for(int i=1; i<=p.size()-1; i++) {
            cout << p[i] << " ";
        }
        if(mins > p[1]) {
            cout << mins << " " << maks;
        }
        cout << endl;
        if(maks > p[p.size()-1]) {
            cout << maks << " " << mins << " ";
        }
        for(int i=p.size()-1; i>=1; i--) {
            cout << p[i] << " ";
        }
        if(maks < p[p.size()-1]) {
            cout << maks << " " << mins << " ";
        }
        cout << endl;
        return 0;
    }
    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] << " ";
      |                  ~^~~~~~~~~~~
zagonetka.cpp:140:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  140 |         for(int i=1; i<=p.size()-1; i++) {
      |                      ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 2 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 6 ms 208 KB Output is correct
6 Correct 7 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 252 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 -