# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
58728 |
2018-07-19T03:26:32 Z |
ksun48 |
Library (JOI18_library) |
C++14 |
|
806 ms |
780 KB |
#include "library.h"
#include <bits/stdc++.h>
using namespace std;
int check(int n, int a, int b){
vector<int> ask(n, 0);
ask[a] = ask[b] = 1;
if(Query(ask) == 1){
return 1;
}
return 0;
}
void Solve(int N) {
int n = N;
vector<vector<int> > groups;
for(int i = 0; i < n; i++){
groups.push_back({i});
}
while(groups.size() > 1){
vector<int> inside;
for(int j = 0; j < groups.size(); j++){
inside.push_back(j);
}
while(inside.size() > 2){
vector<int> newinside;
int bb = min((int)inside.size() - 1, max(2, 2 * (int)sqrt(inside.size()) ) );
//cout << inside.size() << " " << bb << endl;
random_shuffle(inside.begin(), inside.end());
for(int i = 0; i < bb; i++){
newinside.push_back(inside[i]);
}
vector<int> ask(n, 0);
for(int x : newinside){
for(int a : groups[x]){
ask[a] = 1;
}
}
int b = Query(ask);
//assert(b <= newn1);
if(b < bb){
inside = newinside;
}
}
vector<vector<int> > newgroups;
vector<vector<int> > good;
for(int i = 0; i < groups.size(); i++){
if(i != inside[0] && i != inside[1]){
newgroups.push_back(groups[i]);
} else {
good.push_back(groups[i]);
}
}
vector<int> ans;
if(check(n, good[0][0], good[1][0])){
reverse(good[0].begin(), good[0].end());
} else if(check(n, good[0][good[0].size() - 1], good[1][0])){
} else if(check(n, good[0][0], good[1][good[1].size()-1])){
reverse(good[0].begin(), good[0].end());
reverse(good[1].begin(), good[1].end());
} else if(check(n, good[0][good[0].size() - 1], good[1][good[1].size() - 1])){
reverse(good[1].begin(), good[1].end());
} else {
//assert(0);
}
ans.insert(ans.end(), good[0].begin(), good[0].end());
ans.insert(ans.end(), good[1].begin(), good[1].end());
newgroups.push_back(ans);
groups = newgroups;
}
vector<int> ans = groups[0];
for(int j = 0; j < ans.size(); j++){
ans[j]++;
//cout << ans[j] << " ";
}
//cout << endl;
Answer(ans);
}
Compilation message
library.cpp: In function 'void Solve(int)':
library.cpp:22:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j = 0; j < groups.size(); j++){
~~^~~~~~~~~~~~~~~
library.cpp:48:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < groups.size(); i++){
~~^~~~~~~~~~~~~~~
library.cpp:73:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j = 0; j < ans.size(); j++){
~~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
71 ms |
248 KB |
Output is correct |
2 |
Correct |
48 ms |
436 KB |
Output is correct |
3 |
Correct |
61 ms |
496 KB |
Output is correct |
4 |
Correct |
62 ms |
552 KB |
Output is correct |
5 |
Correct |
62 ms |
552 KB |
Output is correct |
6 |
Correct |
41 ms |
552 KB |
Output is correct |
7 |
Correct |
63 ms |
552 KB |
Output is correct |
8 |
Correct |
63 ms |
552 KB |
Output is correct |
9 |
Correct |
71 ms |
552 KB |
Output is correct |
10 |
Correct |
30 ms |
552 KB |
Output is correct |
11 |
Correct |
2 ms |
552 KB |
Output is correct |
12 |
Correct |
1 ms |
552 KB |
Output is correct |
13 |
Correct |
2 ms |
552 KB |
Output is correct |
14 |
Correct |
3 ms |
552 KB |
Output is correct |
15 |
Correct |
3 ms |
552 KB |
Output is correct |
16 |
Correct |
7 ms |
552 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
71 ms |
248 KB |
Output is correct |
2 |
Correct |
48 ms |
436 KB |
Output is correct |
3 |
Correct |
61 ms |
496 KB |
Output is correct |
4 |
Correct |
62 ms |
552 KB |
Output is correct |
5 |
Correct |
62 ms |
552 KB |
Output is correct |
6 |
Correct |
41 ms |
552 KB |
Output is correct |
7 |
Correct |
63 ms |
552 KB |
Output is correct |
8 |
Correct |
63 ms |
552 KB |
Output is correct |
9 |
Correct |
71 ms |
552 KB |
Output is correct |
10 |
Correct |
30 ms |
552 KB |
Output is correct |
11 |
Correct |
2 ms |
552 KB |
Output is correct |
12 |
Correct |
1 ms |
552 KB |
Output is correct |
13 |
Correct |
2 ms |
552 KB |
Output is correct |
14 |
Correct |
3 ms |
552 KB |
Output is correct |
15 |
Correct |
3 ms |
552 KB |
Output is correct |
16 |
Correct |
7 ms |
552 KB |
Output is correct |
17 |
Correct |
806 ms |
780 KB |
Output is correct |
18 |
Correct |
697 ms |
780 KB |
Output is correct |
19 |
Correct |
804 ms |
780 KB |
Output is correct |
20 |
Correct |
693 ms |
780 KB |
Output is correct |
21 |
Correct |
581 ms |
780 KB |
Output is correct |
22 |
Correct |
746 ms |
780 KB |
Output is correct |
23 |
Correct |
679 ms |
780 KB |
Output is correct |
24 |
Correct |
189 ms |
780 KB |
Output is correct |
25 |
Correct |
652 ms |
780 KB |
Output is correct |
26 |
Correct |
587 ms |
780 KB |
Output is correct |
27 |
Correct |
192 ms |
780 KB |
Output is correct |
28 |
Correct |
714 ms |
780 KB |
Output is correct |
29 |
Correct |
687 ms |
780 KB |
Output is correct |
30 |
Correct |
722 ms |
780 KB |
Output is correct |