# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
994813 |
2024-06-08T06:40:08 Z |
Dzadzo |
Library (JOI18_library) |
C++14 |
|
0 ms |
0 KB |
#include <bits/stdc++.h>
#include "library.h"
#define ll long long
#define pb push_back
#define S second
#define F first
#define pii pair<int,int>
#define vi vector <int>
#define vvi vector <vi>
#define vvvi vector <vvi>
#define vp vector <pii>
#define vvp vector <vp>
#define vb vector <bool>
#define vvb vector <vb>;
#define INF INT_MAX
#define MOD 1000000007
#define MAXN 100000
using namespace std;
/*int Query(const vi &v){
for (int x:v)cout<<x;cout<<"\n";
int res;
cin>>res;
return res;
}
void Answer(const vi &v){
cout<<"ANS";
for (int x:v)cout<<x<<" ";
}*/
vvi arr;
int n;
int get(int l,int r,int idx1,int idx2){
vi M(n);
for (int i=l;i<=r;i++){
for (int x:arr[i])M[x-1]=1;
}
if(idx1)M[idx1-1]=1;
if(idx2)M[idx2-1]=1;
return Query(M);
}
void solve(int N){
n=N;
arr.pb({1});
int res=0;
for (int i=2;i<=n;i++){
int val=get(0,arr.size()-1,i,0);
if (val==res+1){
arr.pb({i});
res++;
}else if (val==res){
int ind=-1;
for (int bit=9;bit>=0;bit--){
if (ind+(1<<bit)>=arr.size())continue;
if (get(1,ind+(1<<bit),i,0)>get(1,ind+(1<<bit),0,0))ind+=(1<<bit);
}
ind++;//aq aris i
if (get(0,0,arr[ind][0],i)==1){
arr[ind].insert(arr[ind].begin(),i);
}else{
arr[ind].pb(i);
}
}else if (val==res-1){
int ind=-1;
for (int bit=9;bit>=0;bit--){
if (ind+(1<<bit)>=arr.size())continue;
if (get(1,ind+(1<<bit),i,0)>get(1,ind+(1<<bit),0,0))ind+=(1<<bit);
}
ind++;//aq aris i
vi newarr;
if (get(0,0,arr[ind][0],i)==1){
for (int x:arr[ind+1])newarr.pb(x);
newarr.pb(i);
for (int x:arr[ind])newarr.pb(x);
}else{
for (int x:arr[ind])newarr.pb(x);
newarr.pb(i);
for (int x:arr[ind+1])newarr.pb(x);
}
vvi NEWarr;
for (int i=0;i<arr.size();i++){
if (i==ind || i==ind+1)continue;
NEWarr.pb(arr[i]);
}
NEWarr.pb(newarr);
arr=NEWarr;
res--;
}
}
Answer(arr[0]);
}
/*signed main(){
ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
int c;
cin>>c;
solve(c);
}*/
Compilation message
library.cpp: In function 'void solve(int)':
library.cpp:52:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
52 | if (ind+(1<<bit)>=arr.size())continue;
| ~~~~~~~~~~~~^~~~~~~~~~~~
library.cpp:64:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
64 | if (ind+(1<<bit)>=arr.size())continue;
| ~~~~~~~~~~~~^~~~~~~~~~~~
library.cpp:79:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
79 | for (int i=0;i<arr.size();i++){
| ~^~~~~~~~~~~
/usr/bin/ld: /tmp/cchcKu52.o: in function `main':
grader.cpp:(.text.startup+0x25): undefined reference to `Solve(int)'
collect2: error: ld returned 1 exit status