QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#61706 | #1817. AND Permutation | Booksnow | RE | 2ms | 3736kb | C++14 | 1.0kb | 2022-11-14 16:43:08 | 2022-11-14 16:43:11 |
Judging History
answer
#include <bits/stdc++.h>
#define st first
#define nd second
#define db double
#define re register
#define pb push_back
#define mk make_pair
#define int long long
#define ldb long double
#define pii pair<int, int>
#define ull unsigned long long
#define mst(a, b) memset(a, b, sizeof(a))
using namespace std;
const int N = 3e3, INF = 1e15;
inline int read()
{
int s = 0, w = 1;
char ch = getchar();
while(ch < '0' || ch > '9') { if(ch == '-') w *= -1; ch = getchar(); }
while(ch >= '0' && ch <= '9') s = s * 10 + ch - '0', ch = getchar();
return s * w;
}
int n;
int a[N], b[N];
unordered_map<int, int> mp;
signed main()
{
n = read();
for(re int i = 1; i <= n; i++) a[i] = read();
for(re int i = 1; i <= n; i++) b[i] = a[i], mp[b[i]] = i;
for(re int t = 59; t >= 0; t--){
for(re int i = 1; i <= n; i++){
if(a[i] >> t & 1){
int p = mp[b[i] ^ (1 << t)];
swap(b[i], b[p]), mp[b[i]] = i, mp[b[p]] = p;
}
}
}
for(re int i = 1; i <= n; i++) printf("%lld\n", b[i]);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3736kb
input:
6 0 1 4 5 2 6
output:
6 4 2 0 5 1
result:
ok OK!
Test #2:
score: 0
Accepted
time: 2ms
memory: 3452kb
input:
272 315 138 126 6 394 297 44 273 84 200 9 197 396 133 16 46 65 87 86 336 316 174 140 162 250 306 52 188 57 36 63 192 320 388 10 156 15 208 38 32 31 228 30 305 234 384 220 142 72 27 337 110 94 317 304 242 398 209 5 323 29 284 301 309 244 230 261 61 254 266 194 296 275 313 80 206 214 88 308 18 288 106...
output:
4 309 129 416 116 22 275 198 170 55 310 58 114 82 323 273 318 128 168 174 195 81 307 285 5 204 267 67 262 394 256 63 190 122 388 98 304 47 392 398 288 27 289 14 21 126 35 305 182 292 140 145 160 2 206 13 112 46 314 148 290 226 18 10 11 25 210 258 1 244 61 215 196 6 303 49 41 166 202 321 222 149 281 ...
result:
ok OK!
Test #3:
score: -100
Runtime Error
input:
5134 36416 73248 85220 2072 16524 36385 101507 91137 17604 22 640 70530 66850 107792 81952 163 84260 46246 45090 101411 18824 66360 116881 400 50338 109824 17508 122881 98691 99843 36481 1696 102658 27008 2566 4 32900 103171 1153 104706 69923 82280 19616 66849 17540 36870 8352 117777 82156 6785 6780...