제출 #1134783

#제출 시각아이디문제언어결과실행 시간메모리
1134783StefanSebez도서관 (JOI18_library)C++20
0 / 100
11 ms416 KiB
#include <bits/stdc++.h> #include "library.h" using namespace std; #define fi first #define se second #define pb push_back #define ll long long #define ld long double void Solve(int n){ vector<int>temp(n,0); vector<vector<int>>komp; for(int i=0;i<n;i++){ for(int j=0;j<n;j++) temp[j]=0; for(auto j:komp) for(auto k:j) temp[k]=1; bool allzero=true;for(auto j:temp) if(temp[j]) allzero=false; int x=0; if(!allzero) x=Query(temp); temp[i]=1; int x1=Query(temp); if(x<x1){komp.pb({i});continue;} int l=0,r=(int)komp.size()-1,ind=0; while(l<=r){ int mid=l+r>>1; for(int j=0;j<n;j++) temp[j]=0; for(int j=0;j<=mid;j++) for(auto k:komp[j]) temp[k]=1; int y=Query(temp); temp[i]=1; int y1=Query(temp); if(y==y1){ ind=mid;r=mid-1; } else l=mid+1; } for(int j=0;j<n;j++) temp[j]=0; temp[i]=temp[komp[ind][0]]=1; if(Query(temp)==1) reverse(komp[ind].begin(),komp[ind].end()); komp[ind].pb(i); ind++; if(ind<komp.size()){ for(int j=0;j<n;j++) temp[j]=0; for(auto j:komp[ind]) temp[j]=1; temp[i]=1; if(Query(temp)==1){ for(int j=0;j<n;j++) temp[j]=0; temp[i]=temp[komp[ind][0]]=1; if(Query(temp)==2) reverse(komp[ind].begin(),komp[ind].end()); for(auto j:komp[ind]) komp[ind-1].pb(j); for(int j=ind;j+1<komp.size();j++) komp[j]=komp[j+1]; komp.pop_back(); } } //printf("%i:\n",i);for(int j=0;j<komp.size();j++){printf("%i: ",j);for(auto k:komp[j]) printf("%i ",k);printf("\n");} } vector<int> res=komp[0]; for(auto &i:res) i++; Answer(res); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...