#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;
vector <int> mn, mx, g;
int n, mk[N];
bool gd(vector <int> &g)
{
cout << "query ";
for (auto it : g) cout << it << " "; cout << endl;
bool t;
cin >> t;
return t;
}
bool lower(vector <int> &a, vector <int> &b)
{
for (int i = 0; i < sz(a); i++)
{
if (a[i] == b[i]) continue;
return a[i] < b[i];
}
return 1;
}
void rec(int v)
{
if (v == n)
{
if (gd(g))
{
if (sz(mn) == 0 || lower(g, mn)) mn = g;
if (sz(mx) == 0 || lower(mx, g)) mx = g;
}
return;
}
for (int i = 1; i <= n; i++)
{
if (mk[i]) continue;
mk[i] = 1;
g.pb(i);
rec(v + 1);
g.pop_back();
mk[i] = 0;
}
}
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++) {int x; cin >> x;}
rec(0);
cout << "end" << endl;
for (auto it : mn) cout << it << " "; cout << endl;
for (auto it : mx) cout << it << " "; cout << endl;
}
Compilation message
zagonetka.cpp: In function 'bool gd(std::vector<int>&)':
zagonetka.cpp:38:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
for (auto it : g) cout << it << " "; cout << endl;
^~~
zagonetka.cpp:38: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: In function 'int main()':
zagonetka.cpp:103:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
for (auto it : mn) cout << it << " "; cout << endl;
^~~
zagonetka.cpp:103:43: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
for (auto it : mn) cout << it << " "; cout << endl;
^~~~
zagonetka.cpp:105:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
for (auto it : mx) cout << it << " "; cout << endl;
^~~
zagonetka.cpp:105:43: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
for (auto it : mx) cout << it << " "; cout << endl;
^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
6 ms |
384 KB |
Output is correct |
4 |
Correct |
6 ms |
384 KB |
Output is correct |
5 |
Correct |
11 ms |
384 KB |
Output is correct |
6 |
Correct |
14 ms |
384 KB |
Output is correct |
7 |
Correct |
12 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3056 ms |
384 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3029 ms |
384 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3042 ms |
384 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |