Submission #994838

# Submission time Handle Problem Language Result Execution time Memory
994838 2024-06-08T07:19:25 Z Dzadzo Library (JOI18_library) C++14
0 / 100
11 ms 596 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;
map <vi,int >MP;
/*int Query(const vi &v){
    if (!MP[v]){
    	for (int x:v)cout<<x;cout<<"\n";
    	cin>>MP[v];
    }
	return MP[v];
}
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=1;
	for (int i=2;i<=n;i++){
//	    cout<<i<<"\n";
		int val=get(0,arr.size()-1,i,0);
		if (val==res+1){
//		    cout<<"AQ1\n";
			arr.pb({i});
			res++;
		}else if (val==res){
//		    cout<<"AQ2\n";
			int ind=-1;
			for (int bit=9;bit>=0;bit--){
				if (ind+(1<<bit)>=arr.size())continue;
				if (get(0,ind+(1<<bit),i,0)>get(0,ind+(1<<bit),0,0))ind+=(1<<bit);
			}
			ind++;//aq aris i
//			cout<<ind<<"---"<<arr[ind][0]<<"\n";
			if (get(0,-1,arr[ind][0],i)==1){
//			    cout<<"MARJVNIV\n";
				arr[ind].insert(arr[ind].begin(),i);
			}else{
//			     cout<<"MARCXNIV\n";
				arr[ind].pb(i);
			}
		}else if (val==res-1){
//		    cout<<"AQ3\n";
			int ind=-1;
			for (int bit=9;bit>=0;bit--){
				if (ind+(1<<bit)>=arr.size())continue;
				if (get(0,ind+(1<<bit),i,0)>get(0,ind+(1<<bit),0,0))ind+=(1<<bit);
			}
			ind++;//aq aris i
//			cout<<ind<<"---\n";
			vi newarr;
			if (get(0,-1,arr[ind][0],i)==1){
//			     cout<<"MARJVNIV\n";
				for (int x:arr[ind+1])newarr.pb(x);
				if (get(0,-1,arr[ind+1][0],i)==1)reverse(newarr.begin(),newarr.end());
				newarr.pb(i);
				for (int x:arr[ind])newarr.pb(x);
			}else{
//			     cout<<"MARCXNIV\n";
				for (int x:arr[ind])newarr.pb(x);
				if (get(0,-1,arr[ind+1][0],i)==2)reverse(arr[ind+1].begin(),arr[ind+1].end());
				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(){	
	int c;
	cin>>c;
	Solve(c);
}*/

Compilation message

library.cpp: In function 'void Solve(int)':
library.cpp:57:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |     if (ind+(1<<bit)>=arr.size())continue;
      |         ~~~~~~~~~~~~^~~~~~~~~~~~
library.cpp:73:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   73 |     if (ind+(1<<bit)>=arr.size())continue;
      |         ~~~~~~~~~~~~^~~~~~~~~~~~
library.cpp:93:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   93 |    for (int i=0;i<arr.size();i++){
      |                 ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 11 ms 596 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 11 ms 596 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -