QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#875208#2745. Mechanical DollWansur#12.778091 74ms19600kbC++201.9kb2025-01-29 12:56:402025-01-29 12:56:41

Judging History

This is the latest submission verdict.

  • [2025-01-29 12:56:41]
  • Judged
  • [2025-01-29 12:56:40]
  • Submitted

answer

#include "doll.h"
#include <bits/stdc++.h>

using namespace std;

const int maxn = 2e5 + 12;

vector<int> g[maxn];
int n, m;

vector<int> find(vector<int> v) {
    if((int)v.size() <= 1) return v;
    vector<int> res, a, b;
    for(int i = 0; i < v.size(); i += 2) {
        a.push_back(v[i]);
    }
    for(int i = 1; i < v.size(); i += 2) {
        b.push_back(v[i]);
    }
    a = find(a), b = find(b);
    for(int x : a) {
        res.push_back(x);
    }
    for(int x : b) {
        res.push_back(x);
    }
    return res;
}

void create_circuit(int M, std::vector<int> a) {
    n = (int)a.size();
    m = M;

    vector<int> c(m + 1), x, y;
    c[0] = a[0];
    for(int i = 0; i < n - 1; i++) {
        g[a[i]].push_back(a[i + 1]);
    }
    g[a[n - 1]].push_back(0);
    for(int i = 1; i <= m; i++) {
        if((int)g[i].size() == 0) {
            continue;
        }
        if((int)g[i].size() == 1) {
            c[i] = g[i][0];
            continue;
        }

        int t = 1, init = (int)x.size();
        while(t < (int)g[i].size()) {
            t <<= 1;
        }
        c[i] = -(init + 1);
        int sz = t - (int)g[i].size();
        for(int j = 1; j < t + sz; j++) {
            x.push_back(0);
            y.push_back(0);
        }
        reverse(g[i].begin(), g[i].end());
        for(int j = 0; j < sz; j++) {
            g[i].push_back(-(init + t + j));
            x[init + t + j - 1] = -(init + t + j);
            y[init + t + j - 1] = -(init + 1);
        }
        reverse(g[i].begin(), g[i].end());
        g[i] = find(g[i]);
        for(int j = 1; j < t; j++) {
            x[init + j - 1] = -(2 * j + init);
            y[init + j - 1] = -(2 * j + 1 + init);
            if(2 * j >= t) {
                x[init + j - 1] = g[i][2 * j - t];
                y[init + j - 1] = g[i][2 * j + 1 - t];
            }
        }
    }
    answer(c, x, y);
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 2
Accepted

Test #1:

score: 2
Accepted
time: 0ms
memory: 3840kb

input:

9 9
2 9 8 1 3 7 6 4 5

output:

Accepted: 0 0

result:

points 1

Test #2:

score: 2
Accepted
time: 8ms
memory: 9600kb

input:

100000 65536
13224 49549 24094 37805 90252 12892 7340 44487 93869 65919 83328 38749 45169 86649 56693 3303 75024 87778 80950 3269 79176 61578 35845 51581 96551 67857 13907 97387 75768 45565 89490 5018 103 41086 67064 9397 48489 68440 92764 32166 96653 66672 56950 86902 56409 70305 63374 77757 17781 ...

output:

Accepted: 0 0

result:

points 1

Test #3:

score: 2
Accepted
time: 8ms
memory: 8320kb

input:

65537 65537
6441 24592 10760 39557 65462 30956 18436 9519 362 26018 25701 48274 47132 23414 12942 24379 58211 44126 23389 32686 48760 13253 65374 33337 12554 35737 16084 39919 42895 33833 19274 2894 18348 360 23026 58809 17915 58960 25582 45951 19578 25984 17149 34944 20240 62018 17167 52414 47657 4...

output:

Accepted: 0 0

result:

points 1

Test #4:

score: 2
Accepted
time: 10ms
memory: 10880kb

input:

100000 100000
83254 62169 5236 21438 78363 14751 44638 2177 98268 60571 99414 18022 36403 50495 98037 57665 15840 74546 77473 70363 89184 46970 79155 39699 98519 49754 30108 58902 71395 16757 66405 96614 85750 35994 80062 68050 62099 60537 37156 54644 20810 62140 95068 7580 56792 86118 40233 6526 37...

output:

Accepted: 0 0

result:

points 1

Test #5:

score: 2
Accepted
time: 0ms
memory: 3840kb

input:

16 16
10 9 12 15 3 2 8 14 1 5 6 4 13 11 7 16

output:

Accepted: 0 0

result:

points 1

Test #6:

score: 2
Accepted
time: 0ms
memory: 4736kb

input:

100000 16
44135 56348 19047 45933 82429 97231 20613 10472 34398 72594 60486 14499 13048 53662 38600 74603

output:

Accepted: 0 0

result:

points 1

Test #7:

score: 2
Accepted
time: 0ms
memory: 3840kb

input:

1 1
1

output:

Accepted: 0 0

result:

points 1

Subtask #2:

score: 4
Accepted

Test #8:

score: 4
Accepted
time: 21ms
memory: 10368kb

input:

65537 131072
38169 29889 63383 43430 55643 44435 63973 61457 18223 38917 62266 26543 10814 970 44978 20275 62383 23625 55275 37609 18805 62029 32115 42887 25636 51086 64204 11787 41137 16164 3764 59071 41518 13112 48670 57859 63154 43506 4175 38360 56815 16082 35241 41583 11729 45167 16539 36608 524...

output:

Accepted: 65535 131070

result:

points 1

Test #9:

score: 4
Accepted
time: 23ms
memory: 11776kb

input:

100000 131073
61734 73042 59366 33009 62560 73038 44339 86523 7658 34359 76827 68571 83863 26715 88078 65508 68589 49267 62747 51316 8508 22067 59629 33963 92558 84309 55385 62694 77667 76171 19976 83841 19035 4944 24964 37987 53770 8114 2322 56094 74735 17468 73405 5746 83339 10532 76504 26243 1501...

output:

Accepted: 42895 85790

result:

points 1

Test #10:

score: 4
Accepted
time: 35ms
memory: 14248kb

input:

100000 200000
83043 36540 24774 66205 7842 83398 83479 9409 19465 35483 56457 73207 70141 74710 69213 48571 95388 86888 65020 38252 50229 82818 68370 62010 59643 24258 27210 36191 23847 51210 16274 87051 79987 79405 41276 38288 55421 5238 47411 65745 2137 86636 52341 5066 42078 63201 31945 14943 164...

output:

Accepted: 100000 200000

result:

points 1

Test #11:

score: 4
Accepted
time: 0ms
memory: 3840kb

input:

8 16
5 7 3 4 3 8 6 2 1 1 2 5 8 6 4 7

output:

Accepted: 8 16

result:

points 1

Test #12:

score: 4
Accepted
time: 0ms
memory: 3840kb

input:

15 16
9 12 14 2 13 1 6 1 7 7 14 8 11 15 10 3

output:

Accepted: 3 6

result:

points 1

Test #13:

score: 4
Accepted
time: 1ms
memory: 3840kb

input:

1 2
1 1

output:

Accepted: 1 2

result:

points 1

Subtask #3:

score: 6.77809
Acceptable Answer

Test #14:

score: 6.77809
Acceptable Answer
time: 53ms
memory: 17800kb

input:

66666 199998
46730 34215 30702 41294 43268 29126 13518 38942 42908 58361 10352 13453 61990 51635 45179 17080 11893 59293 8765 48892 9847 29159 4183 35752 44930 54866 19016 8489 9471 61999 29220 3802 39755 15070 38640 20910 16621 20205 2930 36405 53436 33759 40537 24283 20254 60792 29716 4450 42478 2...

output:

Accepted: 266664 666660

result:

points 0.67780908820

Test #15:

score: 10
Accepted
time: 27ms
memory: 9016kb

input:

32769 131076
8829 30944 26536 24377 6124 4543 32353 7058 21103 11122 8198 19529 22301 21270 5215 18906 18846 6914 15353 13819 23827 7837 2206 24007 14973 31637 14305 14695 12132 25477 27646 4903 7744 21814 3025 21061 7859 19065 18647 3167 7995 214 20861 11297 10612 2743 15912 1665 3400 16962 21692 1...

output:

Accepted: 98307 262152

result:

points 1

Test #16:

score: 10
Accepted
time: 44ms
memory: 11768kb

input:

50000 200000
25241 16870 16272 15837 32662 3912 16150 5512 1699 27980 13997 38374 4182 6506 22600 19818 24607 19180 47790 36167 5578 47683 2665 29615 14997 23315 11250 6094 11596 26683 32069 37141 39632 23911 21360 40327 30746 10367 15847 2870 2633 10146 44047 44376 20751 46745 32075 23491 36385 240...

output:

Accepted: 150000 400000

result:

points 1

Test #17:

score: 10
Accepted
time: 47ms
memory: 14572kb

input:

80000 199999
67677 31754 12492 71459 57465 31660 26707 49315 17519 5333 27531 24811 45788 49713 59693 9524 50044 28153 9079 41619 45764 20105 50079 56215 16830 30752 51327 33056 36375 65817 27999 17844 21350 67753 21082 51366 26671 60038 15168 20310 9391 3814 20442 53969 44560 58065 12792 34443 1381...

output:

Accepted: 180359 443884

result:

points 1

Test #18:

score: 10
Accepted
time: 0ms
memory: 3840kb

input:

5 16
2 5 2 3 3 1 1 4 4 5 3 4 2 4 5 1

output:

Accepted: 19 48

result:

points 1

Test #19:

score: 10
Accepted
time: 0ms
memory: 3840kb

input:

4 16
4 2 4 4 3 3 3 2 2 1 1 3 2 1 1 4

output:

Accepted: 12 32

result:

points 1

Test #20:

score: 10
Accepted
time: 1ms
memory: 3840kb

input:

6 16
2 6 3 6 1 6 4 5 1 3 6 3 1 2 3 2

output:

Accepted: 14 36

result:

points 1

Test #21:

score: 10
Accepted
time: 1ms
memory: 3840kb

input:

1 3
1 1 1

output:

Accepted: 4 10

result:

points 1

Test #22:

score: 10
Accepted
time: 0ms
memory: 3840kb

input:

1 4
1 1 1 1

output:

Accepted: 3 8

result:

points 1

Subtask #4:

score: 0
Wrong Answer

Test #23:

score: 5.11111
Acceptable Answer
time: 0ms
memory: 3840kb

input:

5 16
2 4 2 4 5 5 2 4 5 4 2 2 5 5 4 1

output:

Accepted: 30 90

result:

points 0.51111111110

Test #24:

score: 5.25
Acceptable Answer
time: 0ms
memory: 3840kb

input:

3 16
2 3 3 2 2 1 2 1 2 2 1 1 3 3 3 1

output:

Accepted: 29 88

result:

points 0.5250

Test #25:

score: 0
Wrong Answer
time: 0ms
memory: 3840kb

input:

3 16
3 3 3 3 1 1 3 3 3 2 3 3 2 1 1 1

output:

Accepted: 33 110

result:

points 0

Subtask #5:

score: 0
Wrong Answer

Test #31:

score: 0
Wrong Answer
time: 0ms
memory: 3840kb

input:

1 33
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

output:

Accepted: 94 446

result:

points 0

Subtask #6:

score: 0
Wrong Answer

Test #35:

score: 28
Acceptable Answer
time: 74ms
memory: 19144kb

input:

40000 200000
18605 24497 29838 20963 4861 7592 1633 39477 36565 8297 18190 30474 13552 13537 21338 11904 20265 31867 16132 3720 10773 14695 7860 2766 29 34536 36990 22269 35364 15921 24814 6064 39832 24011 17689 20704 9159 7612 1993 36334 29110 2976 29779 10914 25954 17922 39388 28558 30311 7769 195...

output:

Accepted: 400000 1200000

result:

points 0.50

Test #36:

score: 0
Wrong Answer
time: 66ms
memory: 19600kb

input:

22222 199998
21860 20050 2547 7619 18845 10292 5840 12001 10794 21463 8160 5225 21572 20104 506 7873 2707 19469 10521 11887 1259 2270 7670 4518 14806 17149 21917 5374 5087 6035 8782 14146 11788 14684 535 9352 1093 7008 12761 6614 6464 777 16429 3786 4907 19935 823 4098 8350 12958 15597 4748 22092 21...

output:

Wrong Answer: over 400000 switches

result:

wrong answer