# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
310330 | 2020-10-06T16:42:23 Z | galca | Zagonetka (COI18_zagonetka) | C++14 | 2 ms | 384 KB |
#include <iostream> #include <vector> using namespace std; int si, sj; bool valid(vector<int>& perm) { return perm[si] < perm[sj]; } int main() { int n; cin >> n; int i, j; vector<int> p(n); for (i = 0; i < n; i++) { cin >> p[i]; } //cin >> si >> sj; // assume 1 cond bool found = false; for (i = 0; i < n - 1; i++) { for (j = i + 1; j < n; j++) { //vector<int> q; cout << "query"; int k; for (k = 0; k < i; k++) { cout << " " << p[k]; //q.push_back(p[k]); } cout << " " << p[j]; //q.push_back(p[j]); ++k; for (; k < j; k++) { cout << " " << p[k]; //q.push_back(p[k]); } cout << " " << p[i]; //q.push_back(p[i]); ++k; for (; k < n; k++) { cout << " " << p[k]; //q.push_back(p[k]); } cout << endl; // endl auto-flushes int result1; // = valid(q); cin >> result1; if (!result1) { found = true; break; } } if (found) { break; } } vector<int> minp(n); vector<int> maxp(n); cout << "end"; int k; int minval = 0; int maxval = n-1; for (k = 0; k < i; k++) { minp[k] = minval++; maxp[k] = maxval--; } if (k != n) { if (p[i] < p[j]) { minp[i] = minval++; minp[j] = minval++; maxp[j] = maxval--; maxp[i] = maxval--; for (int l = i + 1; l < j; l++) { minp[l] = minval++; maxp[l] = maxval--; } } else { minp[j] = minval++; minp[i] = minval++; maxp[i] = maxval--; maxp[j] = maxval--; for (int l = i + 1; l < j; l++) { minp[l] = minval++; maxp[l] = maxval--; } } for (k = j + 1; k < n; k++) { minp[k] = minval++; maxp[k] = maxval--; } } for (k=0; k < n; k++) { cout << " " << minp[k]+1; } cout << endl; for (k = 0; k < n; k++) { cout << " " << maxp[k]+1; } cout << endl; // endl auto-flushes return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 384 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 256 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 256 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 256 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |