#include <bits/stdc++.h>
#include "grader.h"
using namespace std;
const int MAXN = 256;
const int MOD = 200007;
const int NIL = 0;
int v[MAXN + 1], vrez[MAXN];
int cand[MAXN + 1][MAXN + 1], nrc[MAXN + 1], fr[MAXN + 1], next1[MAXN + 1];
int rez2, maxrez;
int mod(int x) {
return x < 0 ? -x : x;
}
void solve(int n) {
int i, j, x, rez, nr4, nrz;
for (i = 1; i <= n; i++) {
for (j = 1; j <= n; j++) {
cand[i][j] = 1;
}
nrc[i] = n;
}
vector<int> q;
for (i = 1; i <= n; i++) {
while (nrc[i] > 1) {
nrz = n;
for (j = 1; j <= n; j++) {
fr[j] = 1;
}
q.clear();
for (j = 1; j < i; j++) {
q.push_back(v[j]);
fr[v[j]] = 0;
nrz--;
}
//in q sunt indexate de la 0
for (j = i; j <= n; j++) {
nr4 = mod(rand()) % nrz + 1;
x = 1;
while (nr4 > 0) {
nr4 -= fr[x];
x++;
}
x--;
q.push_back(x);
fr[x] = 0;
nrz--;
}
rez = query(q);
rez2++;
if (rez == i - 1) {
//nu sunt pe pozitiile bune cei de la i la n
for (j = i; j <= n; j++) {
nrc[j] -= cand[j][q[j - 1]];
cand[j][q[j - 1]] = 0;
}
} else if (rez == n) {
return;
}
}
x = 1;
while (cand[i][x] == 0) {
x++;
}
v[i] = x;
for (j = i + 1; j <= n; j++) {
nrc[j] -= cand[j][v[i]];
cand[j][v[i]] = 0;
}
}
q.clear();
for (i = 1; i <= n; i++) {
q.push_back(v[i]);
}
query(q);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Correct! Number of queries: 65 |
2 |
Correct |
1 ms |
336 KB |
Correct! Number of queries: 14 |
3 |
Correct |
1 ms |
336 KB |
Correct! Number of queries: 41 |
4 |
Correct |
1 ms |
336 KB |
Correct! Number of queries: 49 |
5 |
Correct |
1 ms |
336 KB |
Correct! Number of queries: 52 |
6 |
Correct |
1 ms |
336 KB |
Correct! Number of queries: 47 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Correct! Number of queries: 65 |
2 |
Correct |
1 ms |
336 KB |
Correct! Number of queries: 14 |
3 |
Correct |
1 ms |
336 KB |
Correct! Number of queries: 41 |
4 |
Correct |
1 ms |
336 KB |
Correct! Number of queries: 49 |
5 |
Correct |
1 ms |
336 KB |
Correct! Number of queries: 52 |
6 |
Correct |
1 ms |
336 KB |
Correct! Number of queries: 47 |
7 |
Correct |
9 ms |
492 KB |
Correct! Number of queries: 800 |
8 |
Correct |
10 ms |
336 KB |
Correct! Number of queries: 900 |
9 |
Correct |
10 ms |
492 KB |
Correct! Number of queries: 900 |
10 |
Correct |
12 ms |
496 KB |
Correct! Number of queries: 1000 |
11 |
Correct |
8 ms |
496 KB |
Correct! Number of queries: 800 |
12 |
Correct |
9 ms |
592 KB |
Correct! Number of queries: 900 |
13 |
Correct |
7 ms |
336 KB |
Correct! Number of queries: 700 |
14 |
Correct |
10 ms |
496 KB |
Correct! Number of queries: 900 |
15 |
Correct |
10 ms |
336 KB |
Correct! Number of queries: 1000 |
16 |
Correct |
9 ms |
336 KB |
Correct! Number of queries: 900 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Correct! Number of queries: 65 |
2 |
Correct |
1 ms |
336 KB |
Correct! Number of queries: 14 |
3 |
Correct |
1 ms |
336 KB |
Correct! Number of queries: 41 |
4 |
Correct |
1 ms |
336 KB |
Correct! Number of queries: 49 |
5 |
Correct |
1 ms |
336 KB |
Correct! Number of queries: 52 |
6 |
Correct |
1 ms |
336 KB |
Correct! Number of queries: 47 |
7 |
Correct |
9 ms |
492 KB |
Correct! Number of queries: 800 |
8 |
Correct |
10 ms |
336 KB |
Correct! Number of queries: 900 |
9 |
Correct |
10 ms |
492 KB |
Correct! Number of queries: 900 |
10 |
Correct |
12 ms |
496 KB |
Correct! Number of queries: 1000 |
11 |
Correct |
8 ms |
496 KB |
Correct! Number of queries: 800 |
12 |
Correct |
9 ms |
592 KB |
Correct! Number of queries: 900 |
13 |
Correct |
7 ms |
336 KB |
Correct! Number of queries: 700 |
14 |
Correct |
10 ms |
496 KB |
Correct! Number of queries: 900 |
15 |
Correct |
10 ms |
336 KB |
Correct! Number of queries: 1000 |
16 |
Correct |
9 ms |
336 KB |
Correct! Number of queries: 900 |
17 |
Runtime error |
206 ms |
704 KB |
Execution killed with signal 13 |
18 |
Halted |
0 ms |
0 KB |
- |