Submission #96413

# Submission time Handle Problem Language Result Execution time Memory
96413 2019-02-09T10:37:51 Z MvC Library (JOI18_library) C++11
100 / 100
516 ms 448 KB
#pragma GCC optimize("O3")
#include "library.h"
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=1e5+50;
const int mod=1e9+7;
using namespace std;
int n,viz[1050];
int get(int rt)
{
	vector<int>v;
	for(int i=1;i<=n;i++)if(!viz[i])v.pb(i);
	while((int)v.size()!=1)
	{
		vector<int>l,r,s(n,0);
		int mid=(int)v.size()/2;
		for(int i=0;i<mid;i++)l.pb(v[i]),s[v[i]-1]=1;
		for(int i=mid;i<v.size();i++)r.pb(v[i]);
		int x=Query(s);
		s[rt-1]=1;
		if(Query(s)==x)v=l;
		else v=r;
	}
	return v[0];
}
void Solve(int N)
{
	n=N;
	if(n==1)
	{
		Answer(vector<int>{1});
		return;
	}
	int r;
	for(int i=1;i<=n;i++)
	{
		vector<int>v;
		for(int j=1;j<=n;j++)
		{
			if(i==j)v.pb(0);
			else v.pb(1);
		}
		if(Query(v)==1)r=i;
	}
	vector<int>ans;
	ans.pb(r);
	viz[r]=1;
	for(int i=2;i<=n;i++)
	{
		int nxt=get(r);
		ans.pb(nxt);
		r=nxt;
		viz[r]=1;
	}
	Answer(ans);
}
/*int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	
    return 0;
}*/

Compilation message

library.cpp: In function 'int get(int)':
library.cpp:29:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=mid;i<v.size();i++)r.pb(v[i]);
                 ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 64 ms 248 KB # of queries: 2570
2 Correct 43 ms 248 KB # of queries: 2569
3 Correct 52 ms 248 KB # of queries: 2700
4 Correct 51 ms 276 KB # of queries: 2698
5 Correct 45 ms 380 KB # of queries: 2706
6 Correct 46 ms 376 KB # of queries: 2712
7 Correct 45 ms 376 KB # of queries: 2712
8 Correct 47 ms 248 KB # of queries: 2591
9 Correct 47 ms 248 KB # of queries: 2693
10 Correct 24 ms 248 KB # of queries: 1581
11 Correct 2 ms 248 KB # of queries: 0
12 Correct 2 ms 376 KB # of queries: 2
13 Correct 2 ms 380 KB # of queries: 5
14 Correct 2 ms 248 KB # of queries: 10
15 Correct 2 ms 376 KB # of queries: 91
16 Correct 3 ms 248 KB # of queries: 209
# Verdict Execution time Memory Grader output
1 Correct 64 ms 248 KB # of queries: 2570
2 Correct 43 ms 248 KB # of queries: 2569
3 Correct 52 ms 248 KB # of queries: 2700
4 Correct 51 ms 276 KB # of queries: 2698
5 Correct 45 ms 380 KB # of queries: 2706
6 Correct 46 ms 376 KB # of queries: 2712
7 Correct 45 ms 376 KB # of queries: 2712
8 Correct 47 ms 248 KB # of queries: 2591
9 Correct 47 ms 248 KB # of queries: 2693
10 Correct 24 ms 248 KB # of queries: 1581
11 Correct 2 ms 248 KB # of queries: 0
12 Correct 2 ms 376 KB # of queries: 2
13 Correct 2 ms 380 KB # of queries: 5
14 Correct 2 ms 248 KB # of queries: 10
15 Correct 2 ms 376 KB # of queries: 91
16 Correct 3 ms 248 KB # of queries: 209
17 Correct 501 ms 376 KB # of queries: 18168
18 Correct 497 ms 248 KB # of queries: 17939
19 Correct 459 ms 320 KB # of queries: 18180
20 Correct 441 ms 248 KB # of queries: 16942
21 Correct 403 ms 376 KB # of queries: 15891
22 Correct 476 ms 248 KB # of queries: 18146
23 Correct 463 ms 252 KB # of queries: 18127
24 Correct 198 ms 248 KB # of queries: 8343
25 Correct 494 ms 252 KB # of queries: 17689
26 Correct 460 ms 448 KB # of queries: 16547
27 Correct 159 ms 320 KB # of queries: 8273
28 Correct 509 ms 248 KB # of queries: 18934
29 Correct 476 ms 324 KB # of queries: 18913
30 Correct 516 ms 248 KB # of queries: 18934