QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#137532 | #2351. Lost in Transfer | PlentyOfPenalty# | 0 | 4ms | 3692kb | C++20 | 3.2kb | 2023-08-10 13:49:38 | 2023-08-10 13:49:42 |
Judging History
answer
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using namespace std;
using vi=vector<int>;
const int N=1e2+9;
int T,n;
string op;
vi p[720];
map<vi,int> mp6;
map<vi,vi> mp5;
vi discret(vi a){
vi b=a;
sort(all(b));
for(int i=0;i<a.size();i++){
a[i]=lower_bound(all(b),a[i])-b.begin();
}
return a;
}
vi transmit(vi a){
sort(all(a));
int x=0;
for(int u:a)x^=u;
// cerr<<"x="<<x<<" "<<p[x].size()<<endl;
vi b[3];
for(int i=0;i<3;i++){
vi c;
for(int j=0;j<6;j++)c.push_back(a[i*6+j]);
for(int k:p[x]){
b[i].push_back(c[k]);
}
}
vi c,t;
c.insert(c.end(),all(b[0]));
c.push_back(a[18]);
c.insert(c.end(),all(b[1]));
c.push_back(a[19]);
c.insert(c.end(),all(b[2]));
for(int i=20;i<a.size();i++){
t.push_back(a[i]);
}
random_shuffle(all(t));
c.insert(c.end(),all(t));
return c;
}
vi operator&&(const vi &a,const vi &b){
vi c;
for(int x:a)
for(int y:b)
if(x==y){
c.push_back(x);
}
return c;
}
vi recover(vi a){
auto calc=[&](int l,int r){
// fprintf(stderr,">>> l=%d r=%d\n",l,r);
vi b;
for(int i=l;i<r;i++){
b.push_back(a[i]);
}
b=discret(b);
// for(int x:b)cerr<<x<<" ";cerr<<endl;
if(b.size()==5){
// fprintf(stderr,"mp5::");for(int x:mp5[b])cerr<<x<<" ";cerr<<endl;
return mp5[b];
}else{
// fprintf(stderr,"mp6::%d\n",mp6[b]);
return vi{mp6[b]};
}
};
vector<int> xors;
auto check=[&](int a,int b,int c){
vi u=calc(0,a)&&calc(a+1,a+b+1)&&calc(a+b+2,a+b+c+2);
if(u.size()){
xors.insert(xors.end(),all(u));
// sort(all(u)),u.erase(unique(all(u)),u.end());
// fprintf(stderr,"! x=%d u[0]=%d u.size()=%d\n",x,u[0],(int)u.size());
// for(int x:u)cerr<<"u="<<x<<endl;
// assert(u.size()==1);
// assert(x==-1||x==u[0]);
// x=u[0];
}
};
if(a.size()>19)check(6,6,6);
check(5,6,6);
check(6,5,6);
check(6,6,5);
assert(xors.size()!=0);
// cerr<<"xors: ";for(int x:xors)cerr<<x<<" ";cerr<<endl;
map<int,int> p;
for(int x:xors)p[x]++;
int x=-1,c=-1;
for(const auto &it:p){
if(it.second>c){
x=it.first;
c=it.second;
}
}
for(int u:a)x^=u;
// cerr<<"! x="<<x<<endl;
if(x){
assert(1<=x&&x<=500);
a.push_back(x);
}
return a;
}
int main(){
#ifdef memset0
freopen("D.in","r",stdin);
#endif
ios::sync_with_stdio(0),cin.tie(0);
vi id={0,1,2,3,4,5};
int cnt=0;
do{
// cerr<<cnt<<endl;
p[cnt]=id;
mp6[id]=cnt;
for(int i=0;i<6;i++){
vi b;
for(int j=0;j<6;j++)
if(i!=j){
b.push_back(id[j]);
}
b=discret(b);
// for(int x:b)cerr<<x<<" ";cerr<<endl;
auto it=mp5.find(b);
if(it==mp5.end()){
mp5[b]={cnt};
}else{
if(find(all(it->second),cnt)==it->second.end()){
it->second.push_back(cnt);
}
}
}
cnt++;
}while(next_permutation(all(id)));
cin>>op>>T;
if(op=="transmit"){
while(T--){
cin>>n;
vi a(n);
for(int i=0;i<n;i++)cin>>a[i];
vi b=transmit(a);
for(int i=0;i<b.size();i++)cout<<b[i]<<" \n"[i+1==b.size()];
}
}else{
while(T--){
cin>>n;
vi b(n);
for(int i=0;i<n;i++)cin>>b[i];
vi a=recover(b);
for(int i=0;i<a.size();i++)cout<<a[i]<<" \n"[i+1==a.size()];
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3620kb
input:
transmit 2 20 97 388 459 467 32 99 98 296 403 325 330 271 87 333 378 267 405 58 426 374 20 125 481 451 150 495 136 444 192 118 26 68 281 120 61 494 339 86 292 100 32
output:
58 32 97 87 99 98 459 271 267 325 296 333 330 467 378 374 403 388 426 405 26 61 100 68 86 32 494 118 125 192 136 150 120 495 281 339 481 444 451 292
input:
recover 2 19 58 32 97 87 99 98 459 271 267 325 296 333 330 467 378 374 403 388 426 19 26 61 100 68 32 494 118 125 192 136 150 120 495 281 339 481 444 451 292
output:
58 32 97 87 99 98 459 271 267 325 296 333 330 467 378 374 403 388 426 405 26 61 100 68 32 494 118 125 192 136 150 120 495 281 339 481 444 451 292 86
result:
ok all correct (2 test cases)
Test #2:
score: 100
Accepted
time: 4ms
memory: 3684kb
input:
transmit 1 20 158 220 174 224 137 134 339 175 147 122 480 26 151 266 474 144 451 301 105 188
output:
26 105 122 134 137 144 474 147 151 158 174 175 188 480 220 224 266 301 339 451
input:
recover 1 19 26 105 122 134 137 144 474 147 151 158 174 175 188 480 220 224 266 301 339
output:
26 105 122 134 137 144 474 147 151 158 174 175 188 480 220 224 266 301 339 451
result:
ok all correct (1 test case)
Test #3:
score: 100
Accepted
time: 4ms
memory: 3692kb
input:
transmit 1 100 170 478 377 395 397 329 488 424 11 337 249 156 489 244 386 400 81 195 264 272 491 24 280 422 365 382 354 91 23 148 469 196 287 191 368 436 132 84 43 126 451 28 94 61 34 301 104 309 127 116 44 82 21 312 222 294 186 112 210 161 261 131 484 219 430 271 310 184 67 149 119 291 125 267 449 ...
output:
15 24 23 11 28 21 94 43 61 49 34 63 44 104 74 84 82 67 91 81 126 355 156 430 236 281 191 287 249 354 422 301 196 119 478 377 386 195 271 309 127 217 382 161 184 312 252 395 397 383 264 489 170 424 125 368 449 400 148 219 411 222 210 491 116 469 460 112 334 310 410 256 365 323 188 389 339 132 329 451...
input:
recover 1 99 15 24 23 11 28 21 94 43 61 49 34 63 44 104 74 84 82 67 91 81 126 355 156 430 236 281 191 287 249 354 422 301 196 119 478 377 386 195 271 309 127 217 382 161 184 312 252 395 397 383 264 489 170 424 125 368 449 400 148 219 411 222 210 491 116 469 460 112 334 310 410 256 365 323 188 389 33...
output:
15 24 23 11 28 21 94 43 61 49 34 63 44 104 74 84 82 67 91 81 126 355 156 430 236 281 191 287 249 354 422 301 196 119 478 377 386 195 271 309 127 217 382 161 184 312 252 395 397 383 264 489 170 424 125 368 449 400 148 219 411 222 210 491 116 469 460 112 334 310 410 256 365 323 188 389 339 132 329 451...
result:
ok all correct (1 test case)
Test #4:
score: 0
Wrong Answer
time: 4ms
memory: 3676kb
input:
transmit 9 20 130 404 101 44 439 315 251 150 63 463 202 322 48 139 15 276 212 332 238 46 30 470 31 62 452 226 135 150 419 30 380 494 32 386 179 253 451 106 384 116 197 80 133 474 151 293 104 54 350 334 433 40 197 419 332 235 451 154 411 319 78 10 474 125 377 93 336 385 256 188 395 66 449 363 94 223 ...
output:
46 63 44 15 48 101 439 150 212 139 130 202 238 463 315 332 276 251 322 404 54 80 32 62 31 30 334 133 150 116 135 106 104 350 226 293 197 253 179 151 433 419 470 474 380 451 386 384 452 494 66 93 10 57 78 38 259 154 188 94 125 171 105 312 235 256 197 223 245 214 444 363 418 479 419 319 474 430 451 39...
input:
recover 9 19 46 63 44 15 48 101 439 150 212 139 130 202 238 463 315 332 276 251 322 29 54 80 32 62 31 30 334 133 150 116 135 106 104 350 293 197 253 179 151 433 419 470 474 380 451 386 384 452 494 39 66 93 10 57 78 38 259 154 188 94 125 171 105 312 235 256 197 223 245 214 444 363 418 419 319 474 4...
output:
46 63 44 15 48 101 439 150 212 139 130 202 238 463 315 332 276 251 322 404 54 80 32 62 31 30 334 133 150 116 135 106 104 350 293 197 253 179 151 433 419 470 474 380 451 386 384 452 494 226 66 93 10 57 78 38 259 154 188 94 125 171 105 312 235 256 197 223 245 214 444 363 418 419 319 474 430 451 395 33...
result:
wrong answer incorrect answer. (test case 4)