Submission

Status:

PPPPPPPPPP

Score: 100

User: Ecir

Problemset: วิศวกรรมข้อมูล

Language: cpp

Time: 0.002 second

Submitted On: 2025-03-09 22:18:31

#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
#define twod array<ll,2>
string w[7];
string s;
string ans;
ll rans=0;
int n;
bool b[5];
int tran(string word){
	ll k=0;
	for(int i=0;i<word.size();i++){
		if(word[i]&1) k+=(1<<(word.size()-1-i));
	}
	return k;
}
void walk(int u,string word){
	if(u==n){
		ll z=tran(word);
//		cout << z << "\n";
		rans=max(rans,z);
//		cout << word << "\n";
		return;
	}
	for(int i=1;i<=n;i++){
		if(b[i]==1) continue;
		b[i]=1;
		walk(u+1,word+w[i]);
		b[i]=0;
	}
}
void build(int x){
	if(x==0) return;
	build(x/2);
	s+=char(x%2+'0');
}
int main(){
	ios::sync_with_stdio(0);cin.tie(0);
	cin >> n;
	for(int i=1;i<=n;i++){
		int z;cin >> z;
		s="";
		build(z);
		w[i]=s;
	}
//	for(int i=1;i<=n;i++) cout << w[i] <<"\n";
	walk(0,"");
	cout << rans;
	return 0;
}