QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#61775 | #1817. AND Permutation | AlienCollapsar | WA | 3ms | 3500kb | C++14 | 588b | 2022-11-14 19:50:59 | 2022-11-14 19:51:02 |
Judging History
answer
#include<cstdio>
#include<iostream>
#include<unordered_map>
using namespace std;
const int Maxn=3e5+5;
int a[Maxn],b[Maxn];
unordered_map<int,int>mp;
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);cout.tie(nullptr);
int n;cin>>n;
for(int i=1;i<=n;++i)cin>>a[i];
for(int i=1;i<=n;++i)b[i]=a[i],mp[b[i]]=i;
for(int j=3;~j;--j){
for(int i=1;i<=n;++i)if(a[i]>>j&1){
int p=mp[b[i]^(1ll<<j)];
swap(b[i],b[p]);mp[b[i]]=i,mp[b[p]]=p;
}
}
for(int i=1;i<=n;++i)cout<<b[i]<<'\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 3348kb
input:
6 0 1 4 5 2 6
output:
6 4 2 0 5 1
result:
ok OK!
Test #2:
score: -100
Wrong Answer
time: 3ms
memory: 3500kb
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:
308 133 112 9 388 294 35 286 90 199 6 194 386 136 31 33 70 80 88 339 307 160 131 172 244 317 59 178 54 43 48 206 323 394 5 147 0 222 41 47 16 234 17 318 228 398 211 129 71 20 338 96 81 306 319 252 384 214 10 320 18 275 290 314 250 232 266 50 240 261 204 295 284 310 94 193 216 87 315 29 303 100 168 1...
result:
wrong answer Bit and of corresponding values not zero.