QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#372595 | #1817. AND Permutation | chuchu# | WA | 1ms | 3524kb | C++20 | 906b | 2024-03-31 16:07:08 | 2024-03-31 16:07:09 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define FINISH cerr << "FINISH" << endl;
#define debug(x) cerr << #x << " == " << x << endl
#define el '\n'
#define fir first
#define sec second
typedef long long ll;
typedef pair<int, int> PII;
const int mod = 1000000007;
const int inf = 0x3f3f3f3f;
const int N = 200020;
void solve()
{
int n;
cin >> n;
map<ll, int> mp;
vector<ll> a(n + 1, 0), b(n + 1, 0);
for (int i = 1; i <= n; i++) {
cin >> a[i];
mp[a[i]] = i;
b[i] = i;
}
for (int i = 60; i >= 1; i--) {
for (int j = 1; j <= n; j++) {
if (a[j] >> i & 1) {
swap(b[j], b[mp[a[j] ^ (1ll << i)]]);
}
}
}
for (int i = 1; i <= n; i++) {
cout << a[b[i]] << " ";
}
cout << endl;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int T = 1;
// cin >> T;
while (T--) {
solve();
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3524kb
input:
6 0 1 4 5 2 6
output:
6 5 2 1 4 0
result:
wrong answer Bit and of corresponding values not zero.