Submission #480448

# Submission time Handle Problem Language Result Execution time Memory
480448 2021-10-16T12:06:53 Z mosquito_006 Xoractive (IZhO19_xoractive) C++17
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
#define ll long long
using namespace std;

ll Ans[105];
ll a[105];

vector<ll> Index[7];
vector<ll> Num[7];

set<ll> All;

map<vector<ll>, ll> mp;

string s;
void Binary(ll a) {
	if (a > 1) Binary(a / 2);
	s += a % 2 + '0';
}

int ask(ll i) {
	return a[i - 1];
}

vector<ll> get_pairwise_xor(vector<ll> v) {
	vector<ll> ans;
	for (ll i = 0; i < v.size(); i++) {
		for (ll j = 0; j < v.size(); j++) {
			ans.push_back(a[v[i] - 1] ^ a[v[j] - 1]);
		}
	}
	sort(ans.begin(), ans.end());
	return ans;
}

int main() {
	ll n;
	cin >> n;

	Ans[1] = ask(1);
	Index[0].push_back(1);

	for (ll i = 0; i < 7; i++) {
		for (ll j = 1; j <= n; j++) {
			if (((1 << i) & j) == 0)
				Index[i].push_back(j);
		}
	}

	for (ll i = 0; i < 7; i++) {
		vector<ll> v, v1;

		v = get_pairwise_xor(Index[i]);
		Index[i].erase(Index[i].begin(), Index[i].begin() + 1);
		v1 = get_pairwise_xor(Index[i]);

		for (ll j = 0; j < v.size(); j++) {
			if (v[j] == 0) {
				v.erase(v.begin(), v.begin() + 1);
				j--;
			}
		}

		for (ll j = 0; j < v1.size(); j++) {
			if (v1[j] == 0) {
				v1.erase(v1.begin(), v1.begin() + 1);
				j--;
			}
		}

		for (ll k = 0; k < v.size(); k++) {
			for (ll j = 0; j < v1.size(); j++) {
				if (v1[j] == v[k]) {
					v1.erase(v1.begin() + j, v1.begin() + j + 1);
					v.erase(v.begin() + k, v.begin() + k + 1);
					k--;
					break;
				}
			}
		}
		Num[i] = v;
		for (ll j = 0; j < Num[i].size(); j++) {
			Num[i][j] ^= Ans[1];
		}
	}
	for (ll i = 0; i < 7; i++) {
		for (ll j : Num[i]) {
			All.insert(j);
		}
	}

	for (ll i = 1; i <= n; i++) {
		s = "";
		Binary(i);
		vector<ll> v;
		ll m = s.size();
		for (ll j = 0; j < 7 - m; j++) {
			s = '0' + s;
		}
		for (ll j = 0; j < s.size(); j++) {
			if (s[j] == '0') v.push_back(7 - j - 1);
		}
		reverse(v.begin(), v.end());
		mp[v] = i;
	}
	set<ll>::iterator it = All.begin();
	while (it != All.end()) {
		vector<ll> v;
		for (ll i = 0; i < 7; i++) {
			for (ll j : Num[i]) {
				if (j == *it) {
					v.push_back(i);
					break;
				}
			}
		}
		Ans[mp[v]] = *it;
		it++;
	}
	cout << n << endl;
	for (ll i = 1; i <= n; i++) {
		cout << Ans[i] << ' ';
	}
}

Compilation message

Xoractive.cpp: In function 'std::vector<long long int> get_pairwise_xor(std::vector<long long int>)':
Xoractive.cpp:27:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |  for (ll i = 0; i < v.size(); i++) {
      |                 ~~^~~~~~~~~~
Xoractive.cpp:28:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |   for (ll j = 0; j < v.size(); j++) {
      |                  ~~^~~~~~~~~~
Xoractive.cpp: In function 'int main()':
Xoractive.cpp:57:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |   for (ll j = 0; j < v.size(); j++) {
      |                  ~~^~~~~~~~~~
Xoractive.cpp:64:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |   for (ll j = 0; j < v1.size(); j++) {
      |                  ~~^~~~~~~~~~~
Xoractive.cpp:71:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   71 |   for (ll k = 0; k < v.size(); k++) {
      |                  ~~^~~~~~~~~~
Xoractive.cpp:72:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   72 |    for (ll j = 0; j < v1.size(); j++) {
      |                   ~~^~~~~~~~~~~
Xoractive.cpp:82:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   82 |   for (ll j = 0; j < Num[i].size(); j++) {
      |                  ~~^~~~~~~~~~~~~~~
Xoractive.cpp:100:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  100 |   for (ll j = 0; j < s.size(); j++) {
      |                  ~~^~~~~~~~~~
/usr/bin/ld: /tmp/cceqiNgs.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cceiBB2q.o:Xoractive.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/cceqiNgs.o: in function `main':
grader.cpp:(.text.startup+0xdc): undefined reference to `guess(int)'
collect2: error: ld returned 1 exit status