QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#137456#2351. Lost in TransferDelay_for_five_minutes#0 16ms3664kbC++204.9kb2023-08-10 12:54:202023-08-10 12:54:34

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-10 12:54:34]
  • 评测
  • 测评结果:0
  • 用时:16ms
  • 内存:3664kb
  • [2023-08-10 12:54:20]
  • 提交

answer

#include<bits/stdc++.h>
const int P = 7079;
int t[11],vis[11];
int fac[11];
int getnumber(std::vector<int>::iterator p) {
    for(int i=0;i<10;i++) {
        t[i] = p[i];
    }
    int ans = 0;
    for(int i=0;i<10;i++) {
        int cnt = 0;
        for(int j=i+1;j<10;j++) {
            if (t[i] > t[j]) cnt ++;
        }
        ans += cnt * fac[10 - i - 1];
    }
    // printf("%d\n",ans);
    return ans;
}
std::vector<int> reorder(std::vector<int> vt,int num) {
    std::vector<int> ans;
    std::sort(vt.begin(),vt.end());
    bool vis[11];
    memset(vis,0,sizeof vis);
    for(int i=0;i<10;i++) {
        int k = 0;
        while(num >= fac[10 - i - 1]) {
            k ++;
            num -= fac[10 - i - 1];
        }
        for(int j=0;j<10;j++) if (!vis[j]) {
            if (k == 0) {
                ans.push_back(vt[j]);
                vis[j] = 1;
                break;
            }
            k--;
        }
    }
    return ans;
}
std::mt19937 rnd(time(0));
namespace Alice {
    int m;
    bool doit(std::vector<int>& a) {
        int A = getnumber(a.begin()), B = getnumber(a.begin() + m - 10);
        if (A % P != 0) {
            std::swap(A,B);
        }
        return (((A % P == 0) && (B % P == 0) && (A==B)) || (A % P != 0) || (B % P != 0));
    }
    bool check(std::vector<int> vt) {
        for(int i=0;i<10;i++) {
            int tmp = vt[i];
            vt.erase(i + vt.begin());
            if (!doit(vt)) return 0;
            vt.insert(vt.begin() + i, tmp);
        }
        for(int i=vt.size() - 10;i<vt.size();i++) {
            int tmp = vt[i];
            vt.erase(i + vt.begin());
            if (!doit(vt)) return 0;
            vt.insert(vt.begin() + i, tmp);
        }
        return 1;
    }
    void solve() {
        std::vector<int> a;
        std::cin >> m;
        std::vector<int> vt1,vt2,vt;
        int r = 0;
        for(int i=1;i<=m;i++) {
            int x;
            std::cin >> x;
            a.push_back(x);
        }
        do{
            vt1.clear(),vt2.clear();
            vt.clear();
            for(int i=1;i<=m;i++) {
                int x = a[i-1];
                r ^= x;
                bool tag1 = 1,tag2 = 1;
                for(auto j : vt1) {
                    if (j == x) tag1 = 0;
                }
                for(auto j : vt2) {
                    if (j == x) tag2 = 0;
                }
                if (vt1.size() < 10 && tag1) vt1.push_back(x);
                else if (vt2.size() < 10 && tag2) vt2.push_back(x);
                else vt.push_back(x);
            }
            // std::cerr << r << std::endl;
            // std::cerr << r * P << std::endl;
            vt1 = reorder(vt1,r * P);
            vt2 = reorder(vt2,r * P);
            std::vector<int> res;
            for(auto i:vt1) {
                res.push_back(i);
            }
            for(auto i:vt) {
                res.push_back(i);
            }
            for(auto i:vt2) {
                res.push_back(i);
            }
            if (check(res)) break;
            for(int i = 0;i < a.size();i++) std::swap(a[i] , a[rnd()%(i + 1)]);
        }while(1);
        for(auto i:vt1) {
            std::cout << i << " ";
        }
        for(auto i:vt) {
            std::cout << i << " ";
        }
        for(auto i:vt2) {
            std::cout << i << " ";
        }
        std::cout << std::endl;
    }
    void Alice() {
        int T;
        std::cin >> T;
        while(T--) {
            solve();
        }
    }
}
namespace Bob {
    void solve() {
        std::vector<int> a;
        int m;
        std::cin >> m;
        int r = 0;
        for(int i=0;i<m;i++) {
            int x;
            std::cin >> x;
            r ^= x;
            a.push_back(x);
        }
        int A = getnumber(a.begin()), B = getnumber(a.begin() + m - 10);
        if (A % P != 0) {
            std::swap(A,B);
        }
        assert(((A % P == 0) && (B % P == 0) && (A==B)) || (A % P != 0) || (B % P != 0));
        if (A == B) {
            for(auto i:a) {
                std::cout << i << " ";
            }
            if (r != A / P) {
                std::cout << ((A / P) ^ r) << "\n"; 
            }
            else {
                std::cout << "\n";
            }
        }
        else {
            for(auto i:a) {
                std::cout << i << " ";
            }
            std::cout << (r ^ (A/P)) << "\n";
        }
    }
    void Bob() {
        int T;
        std::cin >> T;
        while(T--) {
            solve();
        }
    }
}

int main() {
    // freopen("in.txt","r",stdin);
    fac[0] = 1;
    for(int i=1;i<=10;i++) fac[i] = fac[i-1] * i;
    std::string str;
    std::cin >> str;
    if (str == "transmit") {
        // freopen("out.txt","w",stdout);
        Alice::Alice();
    }
    else {
        // freopen("out.txt","r",stdin);
        Bob::Bob();
    }
}

详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 3664kb

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:

98 325 99 296 403 467 388 459 97 32 267 333 271 330 378 426 374 405 87 58 
26 481 495 125 150 444 118 192 451 136 32 339 494 68 100 281 61 120 292 86 

input:

recover
2
19 98 325 99 296 403 467 388 459 97 32 267 333 271 330 378 426 374 405 87 
19 26 481 495 125 444 118 192 451 136 32 339 494 68 100 281 61 120 292 86 

output:

98 325 99 296 403 467 388 459 97 32 267 333 271 330 378 426 374 405 87 58
26 481 495 125 444 118 192 451 136 32 339 494 68 100 281 61 120 292 86 150

result:

ok all correct (2 test cases)

Test #2:

score: 100
Accepted
time: 0ms
memory: 3552kb

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:

122 134 137 147 158 174 175 220 224 339 26 105 144 151 188 266 301 451 474 480 

input:

recover
1
19 122 134 137 147 158 174 175 220 224 339 26 105 144 151 188 266 301 451 474 

output:

122 134 137 147 158 174 175 220 224 339 26 105 144 151 188 266 301 451 474 480

result:

ok all correct (1 test case)

Test #3:

score: 100
Accepted
time: 2ms
memory: 3508kb

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:

337 488 478 424 377 170 329 397 395 11 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 74 383 252 256 372 143 323 334 331 15 460 236 339 410 ...

input:

recover
1
99 337 488 478 424 377 170 329 397 395 11 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 74 383 252 256 372 143 323 334 331 15 460...

output:

337 488 478 424 377 170 329 397 395 11 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 74 383 252 256 372 143 323 334 331 15 460 236 339 410 ...

result:

ok all correct (1 test case)

Test #4:

score: 100
Accepted
time: 2ms
memory: 3580kb

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:

315 63 439 251 150 101 463 44 130 404 238 46 322 212 202 48 332 15 139 276 
470 62 30 150 380 31 226 135 452 419 80 133 474 151 293 104 54 350 334 433 494 116 32 197 384 106 253 179 451 386 
419 451 235 319 411 10 332 154 197 78 449 363 94 223 171 313 430 444 214 448 245 479 38 105 312 418 337 445 5...

input:

recover
9
19 315 63 439 251 150 101 463 44 130 404 238 46 322 212 202 48 332 15 139 
29 470 62 30 150 380 31 226 135 452 419 80 133 474 151 104 54 350 334 433 494 116 32 197 384 106 253 179 451 386 
39 419 451 235 319 411 10 332 154 197 78 449 363 94 223 171 313 430 444 214 448 245 479 38 312 418 33...

output:

315 63 439 251 150 101 463 44 130 404 238 46 322 212 202 48 332 15 139 276
470 62 30 150 380 31 226 135 452 419 80 133 474 151 104 54 350 334 433 494 116 32 197 384 106 253 179 451 386 293
419 451 235 319 411 10 332 154 197 78 449 363 94 223 171 313 430 444 214 448 245 479 38 312 418 337 445 57 259 ...

result:

ok all correct (9 test cases)

Test #5:

score: 100
Accepted
time: 6ms
memory: 3580kb

input:

transmit
81
100 345 473 156 472 449 361 478 451 332 324 120 264 105 37 287 102 369 417 331 458 284 55 25 115 279 489 257 468 463 200 174 431 408 492 411 227 140 303 89 35 12 371 169 139 485 480 20 373 220 211 330 138 228 466 432 44 166 80 443 24 92 21 160 376 351 190 214 173 132 322 163 340 7 282 40...

output:

156 449 478 345 332 472 473 361 324 451 284 55 25 115 279 489 257 468 463 200 174 431 408 492 411 227 140 303 89 35 12 371 169 139 485 480 20 373 220 211 330 138 228 466 432 44 166 80 443 24 92 21 160 376 351 190 214 173 132 322 163 340 7 282 409 498 114 207 347 193 77 233 476 53 275 358 151 71 38 4...

input:

recover
81
99 156 449 478 345 332 472 473 361 324 451 284 55 25 115 279 489 257 468 463 200 174 431 408 492 411 227 140 303 89 35 12 371 169 139 485 480 20 373 220 211 330 138 228 466 432 44 166 80 443 24 92 21 160 376 351 190 214 173 132 322 163 340 7 282 409 498 114 207 347 193 77 233 476 53 275 3...

output:

156 449 478 345 332 472 473 361 324 451 284 55 25 115 279 489 257 468 463 200 174 431 408 492 411 227 140 303 89 35 12 371 169 139 485 480 20 373 220 211 330 138 228 466 432 44 166 80 443 24 92 21 160 376 351 190 214 173 132 322 163 340 7 282 409 498 114 207 347 193 77 233 476 53 275 358 151 71 38 4...

result:

ok all correct (81 test cases)

Test #6:

score: 100
Accepted
time: 12ms
memory: 3624kb

input:

transmit
1000
20 190 119 5 459 482 162 315 20 210 253 394 444 209 263 382 164 307 457 273 145
20 333 218 169 299 282 401 231 287 486 238 348 128 92 359 142 235 351 368 470 418
20 498 139 5 3 299 275 476 231 402 241 359 53 179 73 335 370 481 184 442 343
20 180 47 216 149 468 94 473 392 264 104 193 63...

output:

5 119 162 459 315 482 210 253 190 20 145 209 263 444 394 457 307 382 273 164 
238 299 218 169 282 333 287 401 486 231 235 359 128 92 348 368 351 418 470 142 
299 5 476 275 241 139 498 3 231 402 359 73 442 343 335 179 481 53 184 370 
104 216 180 468 149 473 264 392 47 94 75 249 193 456 106 480 350 42...

input:

recover
1000
19 5 119 162 459 315 482 210 253 190 20 145 209 263 444 394 457 307 382 273 
19 238 299 218 169 333 287 401 486 231 235 359 128 92 348 368 351 418 470 142 
20 299 5 476 275 241 139 498 3 231 402 359 73 442 343 335 179 481 53 184 370 
19 104 216 180 468 149 473 264 392 47 75 249 193 456 ...

output:

5 119 162 459 315 482 210 253 190 20 145 209 263 444 394 457 307 382 273 164
238 299 218 169 333 287 401 486 231 235 359 128 92 348 368 351 418 470 142 282
299 5 476 275 241 139 498 3 231 402 359 73 442 343 335 179 481 53 184 370 
104 216 180 468 149 473 264 392 47 75 249 193 456 106 480 350 423 26 ...

result:

ok all correct (1000 test cases)

Test #7:

score: 100
Accepted
time: 4ms
memory: 3512kb

input:

transmit
1000
21 474 401 176 47 127 134 166 11 223 37 224 345 273 482 91 289 467 267 469 250 204
20 79 234 415 431 21 440 242 191 441 44 97 52 500 320 436 214 308 381 474 102
21 309 292 88 264 387 127 221 438 61 320 477 482 62 277 17 263 364 37 68 214 446
21 83 393 34 274 463 366 203 404 246 477 342...

output:

223 37 401 47 474 176 134 127 166 11 204 467 224 469 250 482 345 273 267 289 91 
79 441 191 415 431 242 440 21 44 234 102 500 214 381 436 320 474 52 97 308 
221 438 320 264 309 88 292 61 127 387 446 68 482 364 214 277 37 263 17 62 477 
366 274 83 203 477 404 246 393 34 463 336 342 313 13 35 449 427 ...

input:

recover
1000
20 223 401 47 474 176 134 127 166 11 204 467 224 469 250 482 345 273 267 289 91 
19 79 441 191 415 242 440 21 44 234 102 500 214 381 436 320 474 52 97 308 
20 221 438 320 264 309 88 292 61 127 387 446 68 482 214 277 37 263 17 62 477 
20 366 274 83 203 477 404 246 393 34 463 342 313 13 3...

output:

223 401 47 474 176 134 127 166 11 204 467 224 469 250 482 345 273 267 289 91 37
79 441 191 415 242 440 21 44 234 102 500 214 381 436 320 474 52 97 308 431
221 438 320 264 309 88 292 61 127 387 446 68 482 214 277 37 263 17 62 477 364
366 274 83 203 477 404 246 393 34 463 342 313 13 35 449 427 137 363...

result:

ok all correct (1000 test cases)

Test #8:

score: 100
Accepted
time: 16ms
memory: 3580kb

input:

transmit
1000
20 197 246 277 239 452 263 54 349 229 55 458 150 154 52 50 312 386 130 110 190
22 108 144 460 193 208 279 454 481 258 257 50 171 65 391 361 34 80 99 213 94 175 413
20 5 112 294 249 174 186 338 138 35 388 429 139 98 358 247 426 303 55 251 293
22 320 489 163 437 49 54 406 303 285 156 143...

output:

349 54 197 229 452 246 277 239 263 55 386 50 110 130 458 154 312 150 190 52 
454 279 257 144 208 460 258 108 193 481 175 413 213 171 94 50 80 361 99 34 65 391 
112 174 5 249 388 35 138 186 294 338 139 251 55 303 429 98 247 293 358 426 
156 303 163 285 406 489 320 437 54 49 405 341 81 143 114 142 340...

input:

recover
1000
19 349 54 197 229 452 246 277 239 263 55 386 50 110 130 458 154 312 150 190 
21 454 279 257 208 460 258 108 193 481 175 413 213 171 94 50 80 361 99 34 65 391 
20 112 174 5 249 388 35 138 186 294 338 139 251 55 303 429 98 247 293 358 426 
21 156 303 163 285 489 320 437 54 49 405 341 81 1...

output:

349 54 197 229 452 246 277 239 263 55 386 50 110 130 458 154 312 150 190 52
454 279 257 208 460 258 108 193 481 175 413 213 171 94 50 80 361 99 34 65 391 144
112 174 5 249 388 35 138 186 294 338 139 251 55 303 429 98 247 293 358 426 
156 303 163 285 489 320 437 54 49 405 341 81 143 114 142 340 468 2...

result:

ok all correct (1000 test cases)

Test #9:

score: 100
Accepted
time: 14ms
memory: 3596kb

input:

transmit
1000
21 283 319 448 52 15 140 382 156 181 154 473 175 329 374 249 134 338 429 341 96 468
21 203 245 384 64 88 485 408 487 380 12 174 198 474 284 238 283 217 315 311 461 436
23 146 37 63 416 132 414 176 246 104 91 441 401 367 286 485 352 265 260 143 182 238 320 405
22 441 40 250 199 478 462 ...

output:

382 156 448 52 154 140 319 15 181 283 468 429 329 473 134 249 175 374 96 338 341 
203 384 485 380 245 88 12 487 408 64 436 238 311 461 284 283 217 174 474 315 198 
91 414 416 246 37 146 176 104 63 132 238 320 405 260 441 485 401 143 352 367 265 182 286 
91 250 199 462 144 223 478 324 40 441 185 360 ...

input:

recover
1000
20 382 448 52 154 140 319 15 181 283 468 429 329 473 134 249 175 374 96 338 341 
20 203 384 485 380 245 88 487 408 64 436 238 311 461 284 283 217 174 474 315 198 
22 91 414 416 246 37 146 176 104 63 132 238 320 405 260 441 485 401 352 367 265 182 286 
21 91 250 199 462 223 478 324 40 44...

output:

382 448 52 154 140 319 15 181 283 468 429 329 473 134 249 175 374 96 338 341 156
203 384 485 380 245 88 487 408 64 436 238 311 461 284 283 217 174 474 315 198 12
91 414 416 246 37 146 176 104 63 132 238 320 405 260 441 485 401 352 367 265 182 286 143
91 250 199 462 223 478 324 40 441 185 360 54 328 ...

result:

ok all correct (1000 test cases)

Test #10:

score: 100
Accepted
time: 8ms
memory: 3576kb

input:

transmit
1000
23 490 304 341 209 204 387 346 46 126 113 207 330 436 91 403 233 296 329 206 194 9 338 86
24 361 463 241 239 385 314 282 287 357 315 52 295 112 56 484 294 451 210 26 232 67 251 358 435
24 385 474 48 174 12 361 23 195 338 8 66 3 297 351 91 367 177 379 227 197 90 322 273 82
22 403 283 30...

output:

304 209 341 46 346 387 126 113 204 490 9 338 86 296 233 329 91 330 403 206 194 207 436 
241 315 385 463 357 282 314 361 287 239 67 251 358 435 52 232 451 484 294 56 210 295 112 26 
48 8 12 195 23 385 361 338 174 474 90 322 273 82 177 3 66 227 91 367 351 297 197 379 
306 58 330 114 283 455 491 403 26...

input:

recover
1000
22 304 341 46 346 387 126 113 204 490 9 338 86 296 233 329 91 330 403 206 194 207 436 
24 241 315 385 463 357 282 314 361 287 239 67 251 358 435 52 232 451 484 294 56 210 295 112 26 
23 8 12 195 23 385 361 338 174 474 90 322 273 82 177 3 66 227 91 367 351 297 197 379 
21 306 58 330 114 ...

output:

304 341 46 346 387 126 113 204 490 9 338 86 296 233 329 91 330 403 206 194 207 436 209
241 315 385 463 357 282 314 361 287 239 67 251 358 435 52 232 451 484 294 56 210 295 112 26 
8 12 195 23 385 361 338 174 474 90 322 273 82 177 3 66 227 91 367 351 297 197 379 48
306 58 330 114 455 491 403 261 7 21...

result:

ok all correct (1000 test cases)

Test #11:

score: 100
Accepted
time: 6ms
memory: 3520kb

input:

transmit
1000
24 39 219 348 492 97 454 61 384 420 356 67 480 450 46 152 378 308 192 180 77 430 176 241 270
22 108 329 255 312 374 102 164 280 34 435 6 89 207 395 250 326 452 351 472 238 454 56
21 450 317 330 179 121 364 146 29 275 289 223 316 148 443 286 415 95 236 435 438 199
22 402 421 130 499 194...

output:

348 61 420 492 454 97 39 219 384 356 430 176 241 270 180 67 378 480 450 77 46 152 308 192 
280 374 164 435 312 108 255 34 329 102 454 56 326 452 238 472 351 207 250 6 395 89 
146 364 317 29 275 330 450 289 121 179 199 223 438 415 95 286 435 443 316 148 236 
51 130 194 421 402 499 238 324 202 54 323 ...

input:

recover
1000
23 348 61 420 492 454 97 39 219 384 356 430 176 241 270 180 67 378 480 450 77 46 308 192 
21 280 374 164 312 108 255 34 329 102 454 56 326 452 238 472 351 207 250 6 395 89 
20 146 364 317 29 275 330 450 289 121 179 199 223 438 95 286 435 443 316 148 236 
21 51 130 194 421 499 238 324 20...

output:

348 61 420 492 454 97 39 219 384 356 430 176 241 270 180 67 378 480 450 77 46 308 192 152
280 374 164 312 108 255 34 329 102 454 56 326 452 238 472 351 207 250 6 395 89 435
146 364 317 29 275 330 450 289 121 179 199 223 438 95 286 435 443 316 148 236 415
51 130 194 421 499 238 324 202 54 323 491 75 ...

result:

ok all correct (1000 test cases)

Test #12:

score: 0
Programme Dangerous Syscalls

input:

transmit
1000
20 11 22 399 471 138 409 256 220 142 105 327 467 73 65 237 78 407 19 27 388
20 284 451 32 97 383 140 448 228 485 187 323 1 444 143 71 466 499 59 500 432
20 326 150 247 429 77 401 81 351 356 104 366 335 437 94 234 175 205 242 78 107
22 254 200 219 479 365 401 372 208 314 13 389 491 194 ...

output:

22 142 409 220 399 105 471 256 138 11 27 78 407 237 388 65 467 327 73 19 
448 228 97 485 284 451 32 140 383 187 466 323 59 500 432 499 1 71 444 143 
150 356 429 77 326 104 401 351 247 81 175 335 437 78 234 107 366 242 205 94 
372 208 219 314 254 479 365 13 200 401 132 432 470 48 194 349 222 496 389 ...

input:


output:


result: