답안 #333349

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
333349 2020-12-05T16:45:47 Z emaborevkovic Xoractive (IZhO19_xoractive) C++17
0 / 100
3 ms 364 KB
#include <bits/stdc++.h>
#include <interactive.h>

using namespace std;

typedef long long ll;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

const int N = 105;
vector <int> v[N];
vector <int> c[N];
vector <pair <int, int> > s;
int ima[N];
map <int, int> m;

vector <int> guess(int n) {
	memset(ima, 0, sizeof ima);
	vector <int> res(n, 0);
	for (int i=0;i<n;i++) {
		v[i].clear();
		c[i].clear();
	}
	for (int i=1;i<n;i++) {
		int sada = i;
		for (int j=7;j>=0;j--) {
			if (sada >= 1<<j) {
				sada -= 1<<j;
				v[j].pb(i+1);
				ima[i]++;
			}
		}
		s.pb(mp(ima[i], i));
	}
	int prvi = ask(1);
	for (int i=0;i<8;i++) {
		if (v[i].size() == 0) continue;
		vector <int> a, b;
		a = get_pairwise_xor(v[i]);
		v[i].pb(1);
		b = get_pairwise_xor(v[i]);
		int pos = 0;
		vector <int> bla;
		for (int j=0;j<a.size();j++) {
			while (pos < b.size() && a[j] != b[pos]) {
				bla.pb(b[pos]);
				pos++;
			} 
			pos++;
		}
		for (int j=0;j<bla.size();j++) {
			if (j == 0) c[i].pb(bla[j]);
			else if (bla[j] != bla[j-1]) c[i].pb(bla[j]);
		}
		for (int j=0;j<c[i].size();j++) {
			c[i][j] ^= prvi;
		}
	}
	sort(s.begin(), s.end());
	reverse(s.begin(), s.end());
	for (auto x : s) {
		int sada = x.ss;
		int curr = 0;
		for (int i=7;i>=0;i--) {
			if (sada >= 1<<i) {
				sada -= 1<<i;
				for (int j=1;j<c[i].size();j++) {
					if (c[i][j] == -1) continue;
					m[c[i][j]]++;
					if (m[c[i][j]] == ima[x.ss]) curr = c[i][j];
				}
			}
		}
		sada = x.ss;
		for (int i=7;i>=0;i--) {
			if (sada >= 1<<i) {
				sada -= 1<<i;
				for (int j=1;j<c[i].size();j++) {
					m[c[i][j]] = 0;
					if (c[i][j] == curr) c[i][j] = -1;
				}
			}
		}
		res[x.ss] = curr;
	}
	res[0] = prvi;
	return res;
}

Compilation message

Xoractive.cpp: In function 'std::vector<int> guess(int)':
Xoractive.cpp:46:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |   for (int j=0;j<a.size();j++) {
      |                ~^~~~~~~~~
Xoractive.cpp:47:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |    while (pos < b.size() && a[j] != b[pos]) {
      |           ~~~~^~~~~~~~~~
Xoractive.cpp:53:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |   for (int j=0;j<bla.size();j++) {
      |                ~^~~~~~~~~~~
Xoractive.cpp:57:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |   for (int j=0;j<c[i].size();j++) {
      |                ~^~~~~~~~~~~~
Xoractive.cpp:69:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   69 |     for (int j=1;j<c[i].size();j++) {
      |                  ~^~~~~~~~~~~~
Xoractive.cpp:80:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   80 |     for (int j=1;j<c[i].size();j++) {
      |                  ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 364 KB Output is not correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 364 KB Output is correct
2 Correct 3 ms 364 KB Output is correct
3 Incorrect 3 ms 364 KB Output is not correct
4 Halted 0 ms 0 KB -