답안 #46826

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
46826 2018-04-23T16:48:59 Z MatheusLealV 도서관 (JOI18_library) C++17
19 / 100
2000 ms 676 KB
#include <bits/stdc++.h>
#define Nmax 1005
#include "library.h"
using namespace std;

#define f first
#define s second

typedef pair<int, int> pii;

int n, used[Nmax], conta = 0;

void Solve(int N_)
{
	n = N_;

	if(n == 1)
	{
		vector<int> aux(1);

		aux[0] = 1;

		return Answer(aux);
	}

	vector<int> ans;

	for(int i = 1; i <= n; i++)
	{
		vector<int> v(n);

		for(int j = 0; j < n; j++) v[j] = 1;

		v[i - 1] = 0;

		if(Query(v) == 1)
		{			
			used[i] = 1;

			ans.push_back(i);

			break;
		}
	}

	for(int i = 1; i < n; i++)
	{
		for(int j = 1; j <= n; j++)
		{
			if(used[j]) continue;

			vector<int> atual(n);

			for(int z = 0; z < ans.size(); z++)
			{
				atual[ ans[z] - 1] = 1;
			}

			atual[j - 1] = 1;

			if(Query(atual) == 1)
			{
				used[j] = 1;

				ans.push_back(j);

				break;
			}
		}
	}

	Answer(ans);
}

Compilation message

library.cpp: In function 'void Solve(int)':
library.cpp:54:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int z = 0; z < ans.size(); z++)
                   ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 136 ms 376 KB Output is correct
2 Correct 111 ms 376 KB Output is correct
3 Correct 173 ms 516 KB Output is correct
4 Correct 152 ms 572 KB Output is correct
5 Correct 163 ms 572 KB Output is correct
6 Correct 141 ms 572 KB Output is correct
7 Correct 173 ms 572 KB Output is correct
8 Correct 148 ms 572 KB Output is correct
9 Correct 168 ms 676 KB Output is correct
10 Correct 46 ms 676 KB Output is correct
11 Correct 2 ms 676 KB Output is correct
12 Correct 2 ms 676 KB Output is correct
13 Correct 2 ms 676 KB Output is correct
14 Correct 2 ms 676 KB Output is correct
15 Correct 3 ms 676 KB Output is correct
16 Correct 4 ms 676 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 136 ms 376 KB Output is correct
2 Correct 111 ms 376 KB Output is correct
3 Correct 173 ms 516 KB Output is correct
4 Correct 152 ms 572 KB Output is correct
5 Correct 163 ms 572 KB Output is correct
6 Correct 141 ms 572 KB Output is correct
7 Correct 173 ms 572 KB Output is correct
8 Correct 148 ms 572 KB Output is correct
9 Correct 168 ms 676 KB Output is correct
10 Correct 46 ms 676 KB Output is correct
11 Correct 2 ms 676 KB Output is correct
12 Correct 2 ms 676 KB Output is correct
13 Correct 2 ms 676 KB Output is correct
14 Correct 2 ms 676 KB Output is correct
15 Correct 3 ms 676 KB Output is correct
16 Correct 4 ms 676 KB Output is correct
17 Execution timed out 2096 ms 676 KB Time limit exceeded
18 Halted 0 ms 0 KB -