Submission #249255

#TimeUsernameProblemLanguageResultExecution timeMemory
249255VimmerZagonetka (COI18_zagonetka)C++14
100 / 100
93 ms2556 KiB
#include <bits/stdc++.h> //#include <ext/pb_ds/assoc_container.hpp> //#include <ext/pb_ds/tree_policy.hpp> //#pragma GCC optimize("unroll-loops") //#pragma GCC optimize("-O3") //#pragma GCC optimize("Ofast") //#pragma GCC optimize("fast-math") //#pragma GCC optimize("no-stack-protector") #define F first #define S second #define sz(x) int(x.size()) #define pb push_back #define pf push_front #define N 100010 #define M ll(1e9 + 7) #define inf 1e9 + 1e9 using namespace std; //using namespace __gnu_pbds; typedef long double ld; typedef long long ll; typedef short int si; typedef array <int, 6> a6; //typedef tree <int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; map <vector <int>, bool> mp; bool checker(vector <int> &g) { if (mp.find(g) != mp.end()) return mp[g]; cout << "query "; for (auto it : g) cout << it << " "; cout << endl; bool ans; cin >> ans; mp[g] = ans; return ans; } vector <int> ans; int p[150], pos[150], cur = 1, n; bool gd[150][150], bn[150][150], mk[150]; void dfs(int v) { if (mk[v]) return; mk[v] = 1; for (int i = 0; i < n; i++) { if (i == v) continue; if (bn[i][v]) dfs(i); } ans[v] = cur++; } void rec(int v) { if (mk[v]) return; mk[v] = 1; for (int i = 0; i < n; i++) { if (i == v) continue; if (bn[v][i]) rec(i); } ans[v] = cur--; } int main() { //freopen("input.txt", "r", stdin); freopen("output4.txt", "w", stdout); ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for (int i = 0; i < n; i++) { cin >> p[i]; pos[p[i]] = i; gd[p[i]][p[i]] = 1; } for (int len = 1; len <= n; len++) for (int i = 1; i <= n; i++) { int nxt = i + len; if (nxt > n) continue; bool fnd = 0; for (int md = i + 1; md < nxt; md++) if (gd[i][md] && gd[md][nxt]) {fnd = 1; break;} if (fnd) { gd[i][nxt] = 1; continue; } vector <int> v, gr; v.clear(); gr.resize(n); for (int j = 0; j < n; j++) gr[j] = p[j]; for (int md = i; md <= nxt; md++) if (gd[i][md] || gd[md][nxt]) v.pb(md); reverse(v.begin(), v.end()); int j = 0; for (int md = nxt; md >= i; md--) if (gd[i][md]) gr[pos[md]] = v[j++]; for (int md = nxt; md >= i; md--) if (gd[md][nxt]) gr[pos[md]] = v[j++]; gd[i][nxt] = !checker(gr); } for (int i = 1; i <= n; i++) for (int j = i + 1; j <= n; j++) bn[pos[i]][pos[j]] = gd[i][j]; ans.resize(n); for (int i = 0; i < n; i++) dfs(i); cout << "end" << endl; for (auto it : ans) cout << it << " "; cout << endl; cur = n; memset(mk, 0, sizeof(mk)); ans.resize(n); for (int i = 0; i < n; i++) rec(i); for (auto it : ans) cout << it << " "; cout << endl; }

Compilation message (stderr)

zagonetka.cpp: In function 'int main()':
zagonetka.cpp:156:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
     for (auto it : ans) cout << it << " "; cout << endl;
     ^~~
zagonetka.cpp:156:44: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
     for (auto it : ans) cout << it << " "; cout << endl;
                                            ^~~~
zagonetka.cpp:167:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
     for (auto it : ans) cout << it << " "; cout << endl;
     ^~~
zagonetka.cpp:167:44: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
     for (auto it : ans) cout << it << " "; cout << endl;
                                            ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...