제출 #967555

#제출 시각아이디문제언어결과실행 시간메모리
967555lanaskaricaZagonetka (COI18_zagonetka)C++14
27 / 100
16 ms596 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pii pair <int, int> #define fi first #define se second const int MAXN = 110; int n, a, p[MAXN], bio[MAXN]; bool nes; vector <int> perm, rj1, rj2; int pro(int br, int idx) { if (idx == 0) return br + 1; else return br - 1; } void isprobaj(int i, int j, int idx) { int br = 1, d; if (idx == 1) br = n; for (int z = 1; z <= n; z++) { if (z != i && z != j) {cout << br << " "; br = pro(br, idx); continue;} if (z == i) {d = br; br = pro(br, idx); cout << br << " "; br = pro(br, idx);} else {cout << d << " ";} } cout << endl; } void rjesi(int idx) { bool bl = 0; for (int i = n; i > 0; i--) { for (int j = i - 1; j > 0; j--) { cout << "query "; isprobaj(j, i, idx); cin >> a; if (a == 0) continue; if (idx == 1) { cout << "end" << endl; for (int i = 1; i <= n; i++) cout << i << " "; cout << endl; isprobaj(j, i, idx); } else { cout << "end\n"; isprobaj(j, i, idx); for (int i = 1; i <= n; i++) cout << n - i + 1 << " "; cout << endl; } bl = 1; break; } if (bl == 1) break; } } void solve2() { cout << "query "; for (int i = 1; i <= n; i++) cout << i << " "; cout << endl; cin >> a; rjesi(a); } void rek(int x) { if (x == n) { cout << "query "; for (auto e : perm) cout << e << " "; cout << endl; cin >> a; if (a == 1) { rj2.clear(); for (auto e : perm) { rj2.push_back(e); if (nes == 0) rj1.push_back(e); } nes = 1; } } for (int i = 1; i <= n; i++) { if (bio[i] == 1) continue; bio[i] = 1; perm.push_back(i); rek(x + 1); perm.pop_back(); bio[i] = 0; } } void solve1() { nes = 0; rek(0); cout << "end" << endl; for (auto e : rj1) cout << e << " "; cout << endl; for (auto e : rj2) cout << e << " "; cout << endl; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n; for (int i = 0; i < n; i++) cin >> p[i]; if (n <= 6) solve1(); else solve2(); return 0; }

컴파일 시 표준 에러 (stderr) 메시지

zagonetka.cpp: In function 'void rjesi(int)':
zagonetka.cpp:44:17: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   44 |                 for (int i = 1; i <= n; i++) cout << i << " "; cout << endl;
      |                 ^~~
zagonetka.cpp:44:64: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   44 |                 for (int i = 1; i <= n; i++) cout << i << " "; cout << endl;
      |                                                                ^~~~
zagonetka.cpp:50:17: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   50 |                 for (int i = 1; i <= n; i++) cout << n - i + 1 << " "; cout << endl;
      |                 ^~~
zagonetka.cpp:50:72: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   50 |                 for (int i = 1; i <= n; i++) cout << n - i + 1 << " "; cout << endl;
      |                                                                        ^~~~
zagonetka.cpp: In function 'void isprobaj(int, int, int)':
zagonetka.cpp:27:28: warning: 'd' may be used uninitialized in this function [-Wmaybe-uninitialized]
   27 |         else {cout << d << " ";}
      |                            ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...