#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 N 101001
#define M ll(998244353)
#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, 3> a3;
//typedef tree <int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
set <int> from[105], to[105];
vector <int> g;
int cur, n;
bool mk[105];
void rec(int v)
{
if (mk[v]) return;
mk[v] = 1;
for (auto it : from[v]) rec(it);
g[v] = cur++;
}
void dfs(int v)
{
if (mk[v]) return;
mk[v] = 1;
for (auto it : to[v]) dfs(it);
g[v] = cur--;
}
set <pair <int, int> > se;
void maker()
{
memset(mk, 0, sizeof(mk));
g.resize(n);
cur = 1;
for (int i = 0; i < sz(g); i++) rec(i);
}
void maker_more()
{
memset(mk, 0, sizeof(mk));
g.resize(n);
cur = n;
for (int i = 0; i < sz(g); i++) dfs(i);
}
bool ask(vector <int> g)
{
cout << "query "; for (auto it : g) cout << it << " "; cout << endl;
bool f;
cin >> f;
return f;
}
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;
int p[n];
for (int i = 0; i < n; i++) cin >> p[i];
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
{
if (i == j) continue;
if (p[i] < p[j]) {from[j].insert(i); to[i].insert(j); se.insert({i, j});}
}
for (auto it : se)
{
from[it.S].erase(it.F);
to[it.F].erase(it.S);
from[it.F].insert(it.S);
to[it.S].insert(it.F);
maker();
if (!ask(g)) {from[it.S].insert(it.F); to[it.F].insert(it.S);}
from[it.F].erase(it.S);
to[it.S].erase(it.F);
}
maker();
cout << "end" << endl;
for (auto it : g) cout << it << " "; cout << endl;
maker_more();
for (auto it : g) cout << it << " "; cout << endl;
}
Compilation message
zagonetka.cpp: In function 'int main()':
zagonetka.cpp:138:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
for (auto it : g) cout << it << " "; cout << endl;
^~~
zagonetka.cpp:138:42: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
for (auto it : g) cout << it << " "; cout << endl;
^~~~
zagonetka.cpp:142:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
for (auto it : g) cout << it << " "; cout << endl;
^~~
zagonetka.cpp:142:42: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
for (auto it : g) cout << it << " "; cout << endl;
^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
22 ms |
512 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
240 ms |
1024 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |