# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
581999 | 2022-06-23T09:21:42 Z | Abdulmohsen1284 | 도서관 (JOI18_library) | C++14 | 0 ms | 0 KB |
#include <cstdio> #include <vector> #include "library.h" #include"bits/stdc++.h" using namespace std; long long s=0; vector <int> em; void rec(long long cur,vector <int> grp) { long long fr=Query(grp); grp[cur-1]=1; if(fr==Query(grp)) { long long sum=0; grp[cur-1]=0; for(int i=0;i<(int)grp.size();i++) { if(grp[i]==1) sum++; } if(sum==1) { for(int i=0;i<(int)grp.size();i++) { if(grp[i]==1) s=i+1; } return; } if(s==0) Answer(em); vector <int> on=em,tw=em; long long took=0; for(int i=0;took<sum/2;i++) { if(i>=(int)grp.size()) break; if(grp[i]==1) { took++; on[i]=grp[i]; } } for(int i=0;i<(int)grp.size();i++) { if((grp[i]^on[i])==1) tw[i]=1; } grp.clear(); for(int i=0;i<(int)on.size();i++) { if(on[i]==1) { rec(cur,on); break; } } for(int i=0;i<(int)tw.size();i++) { if(tw[i]==1) { rec(cur,tw); return; } } } else return; }