#include "library.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ff first
#define ss second
//#define int long long
int l,r,n,t,m,mid,ans,sum,sum1,sum2,sum0,k,parent[1000005],a[1000005],b[1000005],d[4000005];
vector <int> v,v1,v2;
map <int,int> mp;
string s,s1;
bool b1;
// namespace {
// struct Judge
// {
// int N;
// int A[1002];
// int pos[1002];
// bool f[1002];
// int query_c;
// bool answered;
// void init()
// {
// query_c=0;
// int ret=scanf("%d",&N); ret++;
// answered=false;
// for(int i=0;i<N;i++)ret=scanf("%d",&A[i]),pos[A[i]]=i;
// }
// int query(const vector<int>& M)
// {
// if(query_c==20000)
// {
// puts("Wrong Answer [3]");
// exit(0);
// }
// if(int(M.size())!=N)
// {
// puts("Wrong Answer [1]");
// exit(0);
// }
// bool all_zero=true;
// for(int i=0;i<N;i++)
// {
// if(M[i]!=0&&M[i]!=1)
// {
// puts("Wrong Answer [2]");
// exit(0);
// }
// if(M[i]==1)all_zero=false;
// }
// if(all_zero)
// {
// puts("Wrong Answer [2]");
// exit(0);
// }
// memset(f,0,sizeof(f));
// for(int i=0;i<N;i++)if(M[i])f[pos[i+1]]=true;
// bool las=false;
// int r=0;
// for(int i=0;i<N;i++)
// {
// if(las==false&&f[i]==true)r++;
// las=f[i];
// }
// query_c++;
// return r;
// }
// void answer(const vector<int>& res)
// {
// bool f1=true,f2=true;
// if(int(res.size())!=N)
// {
// puts("Wrong Answer [4]");
// exit(0);
// }
// if(answered)
// {
// puts("Wrong Answer [7]");
// exit(0);
// }
// answered=true;
// memset(f,0,sizeof(f));
// for(int i=0;i<N;i++)
// {
// if(res[i]<=0||res[i]>N)
// {
// puts("Wrong Answer [5]");
// exit(0);
// }
// if(f[res[i]])
// {
// puts("Wrong Answer [6]");
// exit(0);
// }
// f[res[i]]=true;
// }
// for(int i=0;i<N;i++)
// {
// f1&=A[i]==res[i];
// f2&=A[i]==res[N-i-1];
// }
// if(!f1&&!f2)
// {
// puts("Wrong Answer [8]");
// exit(0);
// }
// }
// void end()
// {
// if(!answered)puts("Wrong Answer [7]");
// else printf("Accepted : %d\n",query_c);
// }
// }judge;
// }
// int Query(const vector<int>& M)
// {
// return judge.query(M);
// }
// void Answer(const vector<int>& res)
// {
// judge.answer(res);
// }
void Solve(int n){
if(n==1){
v.pb(1);
Answer(v);
}
for(int i=0;i<n;i++){
v.pb(1);
v1.pb(i+1);
}
for(int i=1;i<=n;i++){
v[i-1]=0;
if(Query(v)==1){
k=i;
break;
}
v[i-1]=1;
}
v2.pb(k);
for(int i=2;i<=n;i++){
// cout<<k<<endl;
for(int j=0;j<v1.size();j++){
if(k==v1[j]){
v1.erase(v1.begin()+j);
break;
}
}
l=0;
r=v1.size()-1;
while(l<=r){
mid=(l+r)/2;
for(int j=0;j<v.size();j++){
v[j]=0;
}
for(int j=l;j<=mid;j++){
v[v1[j]-1]=1;
}
sum=Query(v);
v[k-1]=1;
if(sum==Query(v)){
r=mid;
ans=mid;
if(l==r){
break;
}
}else{
l=mid+1;
}
}
k=v1[ans];
v2.pb(k);
}
Answer(v2);
}
// int main()
// {
// judge.init();
// solve(judge.N);
// judge.end();
// }
Compilation message
library.cpp: In function 'void Solve(int)':
library.cpp:147:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
147 | for(int j=0;j<v1.size();j++){
| ~^~~~~~~~~~
library.cpp:157:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
157 | for(int j=0;j<v.size();j++){
| ~^~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
17 ms |
344 KB |
# of queries: 2625 |
2 |
Correct |
29 ms |
344 KB |
# of queries: 2665 |
3 |
Correct |
17 ms |
340 KB |
# of queries: 2874 |
4 |
Correct |
37 ms |
344 KB |
# of queries: 2803 |
5 |
Correct |
26 ms |
344 KB |
# of queries: 2740 |
6 |
Correct |
32 ms |
344 KB |
# of queries: 2795 |
7 |
Correct |
20 ms |
344 KB |
# of queries: 2812 |
8 |
Correct |
25 ms |
344 KB |
# of queries: 2614 |
9 |
Correct |
26 ms |
340 KB |
# of queries: 2746 |
10 |
Correct |
9 ms |
344 KB |
# of queries: 1646 |
11 |
Incorrect |
0 ms |
344 KB |
Wrong Answer [1] |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
17 ms |
344 KB |
# of queries: 2625 |
2 |
Correct |
29 ms |
344 KB |
# of queries: 2665 |
3 |
Correct |
17 ms |
340 KB |
# of queries: 2874 |
4 |
Correct |
37 ms |
344 KB |
# of queries: 2803 |
5 |
Correct |
26 ms |
344 KB |
# of queries: 2740 |
6 |
Correct |
32 ms |
344 KB |
# of queries: 2795 |
7 |
Correct |
20 ms |
344 KB |
# of queries: 2812 |
8 |
Correct |
25 ms |
344 KB |
# of queries: 2614 |
9 |
Correct |
26 ms |
340 KB |
# of queries: 2746 |
10 |
Correct |
9 ms |
344 KB |
# of queries: 1646 |
11 |
Incorrect |
0 ms |
344 KB |
Wrong Answer [1] |
12 |
Halted |
0 ms |
0 KB |
- |