답안 #654630

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
654630 2022-11-01T03:20:08 Z mousey 도서관 (JOI18_library) C++17
0 / 100
56 ms 300 KB
#include <bits/stdc++.h>
#include "library.h"
#define ll long long
#define vll vector<ll>
#define vllp vector<pair<ll, ll> >
#define vi vector <int>
#define vip vector <pair <int, int> >
#define db double
#define ld long double
#define pdb pair <double, double> 
#define YES cout<<"YES"
#define NO cout<<"NO"
#define nl cout<<"\n"
#define vv vector <vector <ll> >
#define pll pair <ll, ll> 
#define pi pair <int, int>
#define pb push_back
#define f first
#define s second
using namespace std;

const ll mod=1e9+7;
const ll modx=998244353;
const double eps=1e-9;
const ll INF=INT_MAX;
const ll INFINF=LLONG_MAX;
const int MAX_N=1000;

void Solve(int N)
{
	vi ans, v;
	for(int i = 1; i <= N; i++) v.pb(1);
	for(int i = 1; i <= N; i++)
	{
		if(i==1) v[0]=0;
		else v[i-1]=0, v[i-2]=1;
		int report=Query(v);
		if(report==1)
		{
			ans.pb(i);
			break;
		}
	}
	for(int i = 2; i <= N; i++)
	{
		vi cur=v;
		int num=N-i+1;
//		printf("%d\n", num);
//		for(auto i: cur)
//		{
//			printf("%d ", i);
//		}
//		printf("\n");
//		fflush(stdout);
		while(num>1)
		{
			vi a, b;
			int cnt=0;
			for(auto j: cur)
			{
				if(cnt<num/2)
				{
					a.pb(j);
					if(j==1) cnt++;
					b.pb(0);
				}
				else
				{
					b.pb(j);
					a.pb(0);
				}
			}
			int report1=Query(a);
			a[ans[i-2]-1]=1;
			int report2=Query(a);
			a[ans[i-2]-1]=0;
//			printf("array a: ");
//			for(auto i: a) printf("%d ", i);
//			printf("\narray b: ");
//			for(auto i: b) printf("%d ", i);
//			printf("\n");
			if(report1==report2) cur=a, num=cnt;
			else cur=b, num-=cnt;
		}
		for(int i = 0; i < N; i++)
		{
			if(cur[i]==1) ans.pb(i+1), v[i]=0;
		}
//		printf("\n");
	}
//	printf("\n");
//	for(auto i: ans)
//	{
//		printf("%d ", i);
//	}
	Answer(ans);
}
/*
5
4 2 5 3 1
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 208 KB # of queries: 2375
2 Correct 21 ms 208 KB # of queries: 2409
3 Correct 38 ms 208 KB # of queries: 2648
4 Correct 32 ms 208 KB # of queries: 2595
5 Correct 41 ms 208 KB # of queries: 2508
6 Correct 56 ms 208 KB # of queries: 2551
7 Correct 30 ms 208 KB # of queries: 2544
8 Correct 33 ms 208 KB # of queries: 2420
9 Correct 38 ms 208 KB # of queries: 2546
10 Correct 21 ms 208 KB # of queries: 1474
11 Runtime error 1 ms 300 KB Execution killed with signal 13
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 208 KB # of queries: 2375
2 Correct 21 ms 208 KB # of queries: 2409
3 Correct 38 ms 208 KB # of queries: 2648
4 Correct 32 ms 208 KB # of queries: 2595
5 Correct 41 ms 208 KB # of queries: 2508
6 Correct 56 ms 208 KB # of queries: 2551
7 Correct 30 ms 208 KB # of queries: 2544
8 Correct 33 ms 208 KB # of queries: 2420
9 Correct 38 ms 208 KB # of queries: 2546
10 Correct 21 ms 208 KB # of queries: 1474
11 Runtime error 1 ms 300 KB Execution killed with signal 13
12 Halted 0 ms 0 KB -