Submission #835011

#TimeUsernameProblemLanguageResultExecution timeMemory
835011vjudge1Zagonetka (COI18_zagonetka)C++17
9 / 100
7 ms208 KiB
#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); if(mins < p[1] || maks > p[n]) { cout << "end" << endl; cout << mins << " " << maks << " "; for(int i=1; i<=n; i++) { cout << p[i] << " "; } cout << endl; cout << maks << " " << mins << " "; for(int i=n; i>=1; i--) { cout << p[i] << " "; } 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 (stderr)

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] << " ";
      |                  ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...