답안 #480450

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
480450 2021-10-16T12:20:17 Z mosquito_006 Xoractive (IZhO19_xoractive) C++17
컴파일 오류
0 ms 0 KB
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
#include<map>
#define ll long long
using namespace std;

ll a[105];
ll Ans[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 : v) {
		for (ll j : v) {
			ans.push_back(a[i - 1] ^ a[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]);

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

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

		int k = 0;
		for (ll k1 : v) {
			int j = 0;
			for (ll j1 : v1) {
				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;
				}
				j++;
			}
			k++;
		}
		Num[i] = v;
		int j = 0;
		for (ll k : Num[i]) {
			Num[i][j] ^= Ans[1];
			j++;
		}
	}
	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;
		}
		int j = 0;
		for (char c : s) {
			if (c == '0') v.push_back(7 - j - 1);
			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 'int main()':
Xoractive.cpp:62:11: warning: unused variable 'j1' [-Wunused-variable]
   62 |   for (ll j1 : v) {
      |           ^~
Xoractive.cpp:71:11: warning: unused variable 'j1' [-Wunused-variable]
   71 |   for (ll j1 : v1) {
      |           ^~
Xoractive.cpp:82:12: warning: unused variable 'j1' [-Wunused-variable]
   82 |    for (ll j1 : v1) {
      |            ^~
Xoractive.cpp:80:11: warning: unused variable 'k1' [-Wunused-variable]
   80 |   for (ll k1 : v) {
      |           ^~
Xoractive.cpp:94:7: error: redeclaration of 'int j'
   94 |   int j = 0;
      |       ^
Xoractive.cpp:61:7: note: 'int j' previously declared here
   61 |   int j = 0;
      |       ^
Xoractive.cpp:95:11: warning: unused variable 'k' [-Wunused-variable]
   95 |   for (ll k : Num[i]) {
      |           ^