#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <math.h>
#include <vector>
#include <cstring>
#include <ctime>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <ctime>
#define fr first
#define sc second
#define MP make_pair
#define PB push_back
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define lli long long int
#define y1 arayikhalatyan
using namespace std;
lli gcd(lli a, lli b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
lli cg(lli n) {
return n ^ (n >> 1);
}
lli SUM(lli a)
{
return (a * (a + 1) / 2);
}
bool CAN(int x, int y, int n, int m)
{
if (x >= 0 && y >= 0 && x < n && y < m)
{
return true;
}
return false;
}
double her(double x1, double y1, double x2, double y2)
{
return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
string strsum(string a, string b)
{
int p = 0;
string c;
reverse(a.begin(), a.end());
reverse(b.begin(), b.end());
if (b.length() < a.length())
{
for (int i = b.length(); i < a.length(); i++)
{
b += "0";
}
}
else
{
for (int i = a.length(); i < b.length(); i++)
{
a += "0";
}
}
a += "0", b += "0";
for (int i = 0; i < a.length(); i++)
{
c += (a[i] - '0' + b[i] - '0' + p) % 10 + '0';
p = (a[i] + b[i] - '0' - '0' + p) / 10;
}
if (c[c.length() - 1] == '0') c.erase(c.length() - 1, 1);
reverse(c.begin(), c.end());
return c;
}
string strmin(string a, string b)
{
if (a.length() > b.length()) return b;
if (b.length() > a.length()) return a;
for (int i = 0; i < a.length(); i++)
{
if (a[i] > b[i]) return b;
if (b[i] > a[i]) return a;
}
return a;
}
char vow[] = { 'a', 'e', 'i', 'o', 'u' };
int dx[] = { 1, -1, 0, 0 };
int dy[] = { 0, 0, 1, -1 };
const int N = 1e6 + 30;
const lli mod = 1000000007;
int n, ss, mx;
int a[110], pos[110], b[110], c[110];
vector <int> g[110], g1[110], ts;
bool sm, col[110];
void tp()
{
cout << "query ";
for (int i = 1; i <= n; i++)
{
cout << a[i] << " ";
}
cout << endl;
}
void dfs(int v)
{
col[v] = true;
for (auto p : g[v]) if (!col[p]) dfs(p);
ts.PB(v);
}
void dfs1(int v)
{
for (auto p : g[a[v]])
{
if (!b[p]) dfs1(p);
}
b[v] = ++mx;
}
void dfs2(int v)
{
for (auto p : g1[a[v]])
{
if (!c[p]) dfs2(p);
}
c[v] = ++mx;
}
int main()
{
fastio;
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i], pos[a[i]] = i;
for (int i = 2; i <= n; i++)
{
for (int j = i - 1; j >= 1; j--)
{
g[j].PB(i);
ss = i;
for (int k = 1; k < i; k++) if (!col[k]) dfs(k);
for (int k = 1; k <= n; k++) col[k] = false;
reverse(ts.begin(), ts.end());
for (auto p : ts) a[pos[p]] = ss--;
tp();
ts.clear();
cin >> sm;
g[j].pop_back();
if (!sm) g[i].PB(j);
for (int k = 1; k <= n; k++) a[pos[k]] = k;
}
}
cout << "end";
cout << endl;
mx = 0;
for (int i = 1; i <= n; i++)
{
for (int j = 0; j < g[i].size(); j++) g1[g[i][j]].PB(i), g[i][j] = pos[g[i][j]];
//cout << pos[i] << "-";
sort(g[i].begin(), g[i].end());
//for (auto p : g[i]) cout << p << " ";
//cout << endl;
}
for (int i = 1; i <= n; i++)
{
for (int j = 0; j < g1[i].size(); j++) g1[i][j] = pos[g1[i][j]];
//cout << pos[i] << "-";
sort(g1[i].begin(), g1[i].end());
//for (auto p : g1[i]) cout << p << " ";
//cout << endl;
}
for (int i = 1; i <= n; i++)
{
if (!b[i])
dfs1(i);
cout << b[i] << " ";
}
cout << endl;
mx = 0;
for (int i = 1; i <= n; i++)
{
if (!c[i])
dfs2(i);
}
for (int i = 1; i <= n; i++) c[i] = n - c[i] + 1, cout << c[i] << " ";
return 0;
}
Compilation message
zagonetka.cpp: In function 'std::__cxx11::string strsum(std::__cxx11::string, std::__cxx11::string)':
zagonetka.cpp:57:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = b.length(); i < a.length(); i++)
~~^~~~~~~~~~~~
zagonetka.cpp:64:30: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = a.length(); i < b.length(); i++)
~~^~~~~~~~~~~~
zagonetka.cpp:71:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < a.length(); i++)
~~^~~~~~~~~~~~
zagonetka.cpp: In function 'std::__cxx11::string strmin(std::__cxx11::string, std::__cxx11::string)':
zagonetka.cpp:84:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < a.length(); i++)
~~^~~~~~~~~~~~
zagonetka.cpp: In function 'int main()':
zagonetka.cpp:163:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int j = 0; j < g[i].size(); j++) g1[g[i][j]].PB(i), g[i][j] = pos[g[i][j]];
~~^~~~~~~~~~~~~
zagonetka.cpp:171:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int j = 0; j < g1[i].size(); j++) g1[i][j] = pos[g1[i][j]];
~~^~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
248 KB |
Output is correct |
3 |
Correct |
2 ms |
248 KB |
Output is correct |
4 |
Correct |
2 ms |
248 KB |
Output is correct |
5 |
Correct |
2 ms |
248 KB |
Output is correct |
6 |
Correct |
2 ms |
248 KB |
Output is correct |
7 |
Correct |
2 ms |
248 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
15 ms |
376 KB |
Output is correct |
2 |
Correct |
34 ms |
344 KB |
Output is correct |
3 |
Correct |
25 ms |
504 KB |
Output is correct |
4 |
Correct |
36 ms |
376 KB |
Output is correct |
5 |
Correct |
12 ms |
376 KB |
Output is correct |
6 |
Correct |
26 ms |
340 KB |
Output is correct |
7 |
Correct |
9 ms |
248 KB |
Output is correct |
8 |
Correct |
6 ms |
376 KB |
Output is correct |
9 |
Correct |
32 ms |
376 KB |
Output is correct |
10 |
Correct |
15 ms |
436 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
4 ms |
376 KB |
Output is correct |
3 |
Correct |
7 ms |
248 KB |
Output is correct |
4 |
Correct |
8 ms |
376 KB |
Output is correct |
5 |
Correct |
7 ms |
248 KB |
Output is correct |
6 |
Correct |
8 ms |
376 KB |
Output is correct |
7 |
Correct |
4 ms |
248 KB |
Output is correct |
8 |
Correct |
5 ms |
248 KB |
Output is correct |
9 |
Correct |
7 ms |
376 KB |
Output is correct |
10 |
Correct |
5 ms |
376 KB |
Output is correct |
11 |
Correct |
7 ms |
248 KB |
Output is correct |
12 |
Correct |
5 ms |
248 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
65 ms |
376 KB |
Output is correct |
2 |
Correct |
79 ms |
248 KB |
Output is correct |
3 |
Correct |
76 ms |
248 KB |
Output is correct |
4 |
Correct |
77 ms |
332 KB |
Output is correct |
5 |
Correct |
113 ms |
476 KB |
Output is correct |
6 |
Correct |
112 ms |
376 KB |
Output is correct |
7 |
Correct |
77 ms |
472 KB |
Output is correct |
8 |
Correct |
72 ms |
380 KB |
Output is correct |
9 |
Correct |
100 ms |
376 KB |
Output is correct |
10 |
Correct |
91 ms |
248 KB |
Output is correct |
11 |
Correct |
78 ms |
380 KB |
Output is correct |
12 |
Correct |
75 ms |
248 KB |
Output is correct |
13 |
Correct |
86 ms |
376 KB |
Output is correct |
14 |
Correct |
82 ms |
340 KB |
Output is correct |
15 |
Correct |
65 ms |
336 KB |
Output is correct |
16 |
Correct |
83 ms |
248 KB |
Output is correct |