답안 #218855

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
218855 2020-04-02T21:08:19 Z Lawliet Xoractive (IZhO19_xoractive) C++14
6 / 100
5 ms 640 KB
#include "interactive.h"
#include <bits/stdc++.h>

using namespace std;
typedef pair<int,int> pii;

const int MAXN = 110;

int N;

int v[MAXN];

map< int , int > valuesBlock[MAXN];

vector<int> compress(vector<int> a)
{
	int sz = a.size();
	int r = sqrt( sz );

	vector<int> ans;

	for(int i = r ; i < sz ; i += 2)
		ans.push_back( a[i] );

	return ans;
}

vector<int> queryXor(vector<int> a)
{
	vector<int> ans = get_pairwise_xor( a );
	compress( ans );

	return ans;
}

vector<int> queryIntersection(vector<int> a, vector<int> b)
{
	vector< int > ans;
	vector< int > query;

	for(int i = 0 ; i < a.size() ; i++)
		query.push_back( a[i] );

	vector< int > answerWithout = queryXor( query );

	for(int i = 0 ; i < b.size() ; i++)
		query.push_back( b[i] );

	vector< int > answerWith = queryXor( query );
	
	int p = 0;

	for(int j = 0 ; j < answerWith.size() ; j++)
	{
		if( answerWith[j] == answerWithout[p] ) p++;
		else ans.push_back( answerWith[j] );
	}

	return ans;
}

vector< int > guess(int n) 
{
	vector< int > ans( n , 0 );

	int szBlock = 12;
	int qtdBlocks = (n - 1)/szBlock;

	if( n <= 15 )
	{
		for (int i = 1; i <= n; i++)
			ans[i - 1] = ask(i);

		return ans;
	}

	ans[0] = ask(1);

	for(int i = 0 ; i <= qtdBlocks ; i++)
	{
		vector< int > A;
		vector< int > B;

		for(int j = i*szBlock ; j < n && j/szBlock == i ; j++)
			if( j != 0 ) A.push_back( j + 1 );

		B.push_back( 1 );

		vector< int > cur = queryIntersection( A , B );

		for(int j = 0 ; j < cur.size() ; j++)
			valuesBlock[i][ cur[j]^ans[0] ] = 1;
	}

	for(int i = 0 ; i < szBlock ; i++)
	{
		vector< int > A;
		vector< int > B;

		for(int j = i ; j < n ; j += szBlock)
			if( j != 0 ) A.push_back( j + 1 );

		B.push_back( 1 );

		vector< int > cur = queryIntersection( A , B );

		for(int j = 0 ; j < cur.size() ; j++)
		{
			int curValue = cur[j]^ans[0];
			
			for(int t = 0 ; t <= qtdBlocks ; t++)
				if( valuesBlock[t][curValue] == 1 ) ans[ t*szBlock + i ] = curValue;
		}
	}

	return ans;
}

Compilation message

Xoractive.cpp: In function 'std::vector<int> queryIntersection(std::vector<int>, std::vector<int>)':
Xoractive.cpp:41:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0 ; i < a.size() ; i++)
                  ~~^~~~~~~~~~
Xoractive.cpp:46:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0 ; i < b.size() ; i++)
                  ~~^~~~~~~~~~
Xoractive.cpp:53:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int j = 0 ; j < answerWith.size() ; j++)
                  ~~^~~~~~~~~~~~~~~~~~~
Xoractive.cpp: In function 'std::vector<int> guess(int)':
Xoractive.cpp:91:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j = 0 ; j < cur.size() ; j++)
                   ~~^~~~~~~~~~~~
Xoractive.cpp:107:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j = 0 ; j < cur.size() ; j++)
                   ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 4 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -