#include<bits/stdc++.h>
#include "library.h"
#define F first
#define S second
#define pb push_back
using namespace std;
bool SEND = 1;
//int Query(const std::vector<int>& M);
//void Answer(const std::vector<int>& res);
int n, a[2222];
int ask (const std::vector < int > &m) {
if (SEND) {
return Query(m);
}
int n = (int)m.size();
int res = 0;
for (int i = 0, j = 0; i < n; i ++) {
j = i;
while (j < n && m[a[j]]) j++;
if (m[a[i]]) res ++;
i = j;
}
assert(res > 0);
return res;
}
void print (const std:: vector <int> &res) {
if (SEND) {
Answer(res);
} else {
for (auto x : res)
cout << x << ' ';
cout << '\n';
exit(0);
}
}
int go (int n, int x, vector < int > &vec) {
vector < int > all;
for (int i = 0; i < n; i ++) if (vec[i]) {
all.pb(i);
}
//cerr << all.size() << ' ' << x << '\n';
if (all.size() == 1) {
return all.back();
}
vector < int > p1(n, 0);
vector < int > p2(n, 0);
for (int i = 0; i < all.size(); i ++) {
if (i < all.size() / 2) {
p1[all[i]] = 1;
// cerr << all[i] << " r :";
} else {
p2[all[i]] = 1;
// cerr << all[i] << " w :";
}
}
int was = ask(p1);
//cerr << was << '\n';
p1[x] = 1;
if (ask(p1) == was) {
p1[x] = 0;
// cerr << "tur1\n";
return go(n, x, p1);
}
//cerr << "tur2\n";
return go(n, x, p2);
}
void Solve(int n) {
if (n == 1) {
print({1});
return;
}
vector < int > m(n, 1);
int start = -1;
for (int i = 0; i < n; i ++) {
m[i] = 0;
if (ask(m)) {
start = i;
break;
}
m[i] = 1;
}
vector < int > ans;
ans.pb(start);
// cout << start << '\n';
// exit(0);
for (int i = 1; i < n; i ++) {
vector < int > vec(n, 1);
for (auto x : ans) vec[x] = 0;
int x = go(n, ans.back(), vec);
// cout << i << ' ' << x << '\n';
ans.pb(x);
}
for (auto &to : ans) to++;
print(ans);
}
// B...a
Compilation message
library.cpp: In function 'int go(int, int, std::vector<int>&)':
library.cpp:62:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < all.size(); i ++) {
~~^~~~~~~~~~~~
library.cpp:63:9: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (i < all.size() / 2) {
~~^~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
42 ms |
376 KB |
Wrong Answer [8] |
2 |
Incorrect |
45 ms |
248 KB |
Wrong Answer [8] |
3 |
Incorrect |
40 ms |
248 KB |
Wrong Answer [8] |
4 |
Incorrect |
36 ms |
324 KB |
Wrong Answer [8] |
5 |
Incorrect |
44 ms |
376 KB |
Wrong Answer [8] |
6 |
Incorrect |
48 ms |
376 KB |
Wrong Answer [8] |
7 |
Incorrect |
36 ms |
248 KB |
Wrong Answer [8] |
8 |
Incorrect |
42 ms |
376 KB |
Wrong Answer [8] |
9 |
Incorrect |
50 ms |
376 KB |
Wrong Answer [8] |
10 |
Incorrect |
18 ms |
400 KB |
Wrong Answer [8] |
11 |
Correct |
2 ms |
248 KB |
# of queries: 0 |
12 |
Correct |
2 ms |
248 KB |
# of queries: 1 |
13 |
Incorrect |
2 ms |
248 KB |
Wrong Answer [8] |
14 |
Correct |
2 ms |
380 KB |
# of queries: 7 |
15 |
Correct |
3 ms |
248 KB |
# of queries: 77 |
16 |
Incorrect |
4 ms |
324 KB |
Wrong Answer [8] |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
42 ms |
376 KB |
Wrong Answer [8] |
2 |
Incorrect |
45 ms |
248 KB |
Wrong Answer [8] |
3 |
Incorrect |
40 ms |
248 KB |
Wrong Answer [8] |
4 |
Incorrect |
36 ms |
324 KB |
Wrong Answer [8] |
5 |
Incorrect |
44 ms |
376 KB |
Wrong Answer [8] |
6 |
Incorrect |
48 ms |
376 KB |
Wrong Answer [8] |
7 |
Incorrect |
36 ms |
248 KB |
Wrong Answer [8] |
8 |
Incorrect |
42 ms |
376 KB |
Wrong Answer [8] |
9 |
Incorrect |
50 ms |
376 KB |
Wrong Answer [8] |
10 |
Incorrect |
18 ms |
400 KB |
Wrong Answer [8] |
11 |
Correct |
2 ms |
248 KB |
# of queries: 0 |
12 |
Correct |
2 ms |
248 KB |
# of queries: 1 |
13 |
Incorrect |
2 ms |
248 KB |
Wrong Answer [8] |
14 |
Correct |
2 ms |
380 KB |
# of queries: 7 |
15 |
Correct |
3 ms |
248 KB |
# of queries: 77 |
16 |
Incorrect |
4 ms |
324 KB |
Wrong Answer [8] |
17 |
Incorrect |
491 ms |
408 KB |
Wrong Answer [8] |
18 |
Incorrect |
501 ms |
536 KB |
Wrong Answer [8] |
19 |
Incorrect |
492 ms |
420 KB |
Wrong Answer [8] |
20 |
Incorrect |
487 ms |
412 KB |
Wrong Answer [8] |
21 |
Incorrect |
406 ms |
424 KB |
Wrong Answer [8] |
22 |
Incorrect |
512 ms |
496 KB |
Wrong Answer [8] |
23 |
Incorrect |
479 ms |
424 KB |
Wrong Answer [8] |
24 |
Incorrect |
171 ms |
324 KB |
Wrong Answer [8] |
25 |
Incorrect |
473 ms |
452 KB |
Wrong Answer [8] |
26 |
Incorrect |
460 ms |
504 KB |
Wrong Answer [8] |
27 |
Incorrect |
158 ms |
320 KB |
Wrong Answer [8] |
28 |
Correct |
456 ms |
504 KB |
# of queries: 15957 |
29 |
Correct |
473 ms |
412 KB |
# of queries: 15939 |
30 |
Correct |
477 ms |
376 KB |
# of queries: 15957 |