Submission #260798

# Submission time Handle Problem Language Result Execution time Memory
260798 2020-08-11T02:06:38 Z arnold518 Library (JOI18_library) C++14
19 / 100
2000 ms 376 KB
#include "library.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 1000;

int N;
vector<int> todo, T, ans;

void Solve(int _N)
{
	N=_N;

	for(int i=1; i<=N; i++) todo.push_back(i);
	ans=vector<int>(N);

	T=vector<int>(N, 1);
	int now=0;
	for(int j=0; j+1<todo.size(); j++)
	{
		int p=todo[j];
		T[p-1]=0;
		int q=Query(T);
		if(q==1) now=p;
		T[p-1]=1;
	}
	if(now==0) now=todo.back();
	for(int j=0; j<todo.size(); j++) if(todo[j]==now)
	{
		todo.erase(todo.begin()+j);
		break;
	}
	ans[0]=now;
	
	for(int i=2; i<=N; i++)
	{
		T=vector<int>(N, 1);
		for(auto it : todo) T[it-1]=0;
		int now=0;
		for(int j=0; j+1<todo.size(); j++)
		{
			int p=todo[j];
			T[p-1]=1;
			int q=Query(T);
			if(q==1) now=p;
			T[p-1]=0;
		}
		if(now==0) now=todo.back();
		for(int j=0; j<todo.size(); j++) if(todo[j]==now)
		{
			todo.erase(todo.begin()+j);
			break;
		}
		ans[i-1]=now;
	}

	Answer(ans);
}

Compilation message

library.cpp: In function 'void Solve(int)':
library.cpp:23:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int j=0; j+1<todo.size(); j++)
               ~~~^~~~~~~~~~~~
library.cpp:32:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int j=0; j<todo.size(); j++) if(todo[j]==now)
               ~^~~~~~~~~~~~
library.cpp:44:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=0; j+1<todo.size(); j++)
                ~~~^~~~~~~~~~~~
library.cpp:53:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j=0; j<todo.size(); j++) if(todo[j]==now)
                ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 271 ms 256 KB # of queries: 18336
2 Correct 291 ms 256 KB # of queries: 18145
3 Correct 341 ms 256 KB # of queries: 19900
4 Correct 375 ms 256 KB # of queries: 19900
5 Correct 322 ms 256 KB # of queries: 19900
6 Correct 457 ms 256 KB # of queries: 19900
7 Correct 406 ms 256 KB # of queries: 19900
8 Correct 388 ms 256 KB # of queries: 18528
9 Correct 406 ms 256 KB # of queries: 19701
10 Correct 164 ms 256 KB # of queries: 8256
11 Correct 0 ms 256 KB # of queries: 0
12 Correct 0 ms 256 KB # of queries: 1
13 Correct 1 ms 256 KB # of queries: 3
14 Correct 1 ms 256 KB # of queries: 6
15 Correct 2 ms 256 KB # of queries: 105
16 Correct 4 ms 256 KB # of queries: 351
# Verdict Execution time Memory Grader output
1 Correct 271 ms 256 KB # of queries: 18336
2 Correct 291 ms 256 KB # of queries: 18145
3 Correct 341 ms 256 KB # of queries: 19900
4 Correct 375 ms 256 KB # of queries: 19900
5 Correct 322 ms 256 KB # of queries: 19900
6 Correct 457 ms 256 KB # of queries: 19900
7 Correct 406 ms 256 KB # of queries: 19900
8 Correct 388 ms 256 KB # of queries: 18528
9 Correct 406 ms 256 KB # of queries: 19701
10 Correct 164 ms 256 KB # of queries: 8256
11 Correct 0 ms 256 KB # of queries: 0
12 Correct 0 ms 256 KB # of queries: 1
13 Correct 1 ms 256 KB # of queries: 3
14 Correct 1 ms 256 KB # of queries: 6
15 Correct 2 ms 256 KB # of queries: 105
16 Correct 4 ms 256 KB # of queries: 351
17 Execution timed out 3027 ms 376 KB Time limit exceeded
18 Halted 0 ms 0 KB -