QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#122431#87. Devil's Sharebashkort#14 42ms3932kbC++201.8kb2023-07-10 15:02:492024-07-04 00:35:45

Judging History

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

  • [2024-07-04 00:35:45]
  • 评测
  • 测评结果:14
  • 用时:42ms
  • 内存:3932kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-10 15:02:49]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

constexpr int A = 10;

void solve() {
    int k;
    cin >> k;

    int d[A]{};
    for (int i = 1; i < A; ++i) {
        cin >> d[i];
    }

    const int n = accumulate(d, d + A, 0);
    vector<int> ans(n);

    if (k == 2) {
        ans[n - 1] = A - 1;
        while (!d[ans.back()]) {
            --ans.back();
        }
        --d[ans.back()];
        int x = ans.back();
        while (!d[x]) {
            --x;
        }

        int p = n - 2;
        for (int i = 1; i < x; ++i) {
            while (d[i]--) {
                ans[p--] = i;
                if (d[x] > 0) {
                    ans[p--] = x;
                    --d[x];
                }
            }
        }
        while (d[x]--) {
            ans[p--] = x;
        }
    } else {
        int x = 2;

        for (int i = 1; i < k; ++i) {
            ans[n - i] = x;
            if (--d[x] == 0) {
                x -= 1;
            }
        }

        if (d[2] == 0) {
            for (int i = k; i >= n; --i) {
                ans[n - i] = 1;
            }
        } else {
            int cnt = d[2];
            int f = d[1] / cnt, p = 0;
            for (int i = 0; i < cnt; ++i) {
                ans[p++] = 2;
                int s = i + 1 == cnt ? d[1] - f * (cnt - 1) : f;
                for (int t = 0; t < s; ++t) {
                    ans[p++] = 1;
                }
            }
        }
    }

    for (int i = 0; i < n; ++i) {
        cout << ans[i];
    }
    cout << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int test = 1;
    cin >> test;

    while (test--) {
        solve();
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3604kb

input:

1536
4
2 1 2 2 0 0 0 0 0
2
3 2 3 3 0 0 0 0 0
3
1 2 0 3 0 0 0 0 0
4
2 2 3 2 0 0 0 0 0
1
3 3 2 2 0 0 0 0 0
3
1 2 2 0 0 0 0 0 0
3
2 1 2 3 0 0 0 0 0
6
1 3 3 0 0 0 0 0 0
4
1 0 1 2 0 0 0 0 0
4
2 1 2 3 0 0 0 0 0
4
2 3 0 2 0 0 0 0 0
5
3 2 3 3 0 0 0 0 0
3
2 2 1 1 0 0 0 0 0
3
2 3 2 0 0 0 0 0 0
8
1 3 1 3 0 0 0...

output:

0000112
33322141414
000022
000000122
2121210000
00022
00000012
0001222
0222
00000112
0000222
00000001122
000022
2110022
10001222
00000
22210000
00000022
2110000022
32242414
222100
000112
21210
00001122
10011222
13
223131314
000022
2000022
00000
0000001122
022
332221414
00222
10122
222000
0000222
000...

result:

wrong output format Extra information in the output file

Subtask #2:

score: 14
Accepted

Test #2:

score: 14
Accepted
time: 39ms
memory: 3460kb

input:

35960
2
0 0 5 2 0 0 17 0 7
2
0 6 0 15 0 0 0 4 5
2
3 0 0 1 20 0 0 0 8
2
0 5 0 0 15 0 5 7 0
2
0 0 2 11 0 0 4 0 10
2
0 14 0 0 11 0 0 6 1
2
0 0 10 3 0 0 8 0 1
2
0 1 9 0 2 0 0 6 0
2
0 0 0 0 5 0 12 7 3
2
0 0 5 0 0 2 0 8 9
2
7 2 0 0 0 0 0 6 8
2
0 0 0 4 1 0 3 18 0
2
0 0 14 4 8 0 0 0 1
2
0 2 0 0 0 13 3 9 0
2...

output:

7777777777777777749493939393939
888844444444444444422929292929
55555555555555555959595949191919
77777555555555555558582828282828
777744449494949494949493939
55555555555222222228282828282829
4443373737373737373739
553333383838383828
888888877777777777755595959
888888898969693939393939
888888229191919...

result:

ok Correct!

Test #3:

score: 0
Accepted
time: 29ms
memory: 3528kb

input:

23426
2
34 0 0 0 0 3 0 0 8
2
20 1 0 0 0 21 0 0 0
2
18 0 0 0 5 0 0 0 18
2
8 18 0 0 0 27 0 0 0
2
0 0 2 47 0 0 0 0 4
2
0 0 0 36 9 0 5 0 0
2
7 0 0 15 0 0 29 0 0
2
2 0 27 0 0 0 20 0 0
2
0 0 0 3 29 0 0 11 0
2
0 0 0 11 0 0 25 14 0
2
0 7 0 16 0 22 0 0 0
2
0 0 0 1 0 22 20 0 0
2
0 0 0 37 0 3 0 7 0
2
20 0 0 0 ...

output:

666111111111111111111111111111919191919191919
261616161616161616161616161616161616161616
55555191919191919191919191919191919191919
62626262626262626262626262626262626261616161616161616
44444444444444444444444444444444444444444444449493939
55555555544444444444444444444444444444444747474747
7777777474...

result:

ok Correct!

Test #4:

score: 0
Accepted
time: 33ms
memory: 3484kb

input:

19600
2
0 7 0 9 0 0 3 32 0
2
0 0 0 0 23 22 4 2 0
2
0 0 6 0 0 2 33 0 10
2
0 12 0 7 0 11 21 0 0
2
41 0 0 5 3 0 2 0 0
2
19 0 0 13 6 0 0 0 13
2
12 6 0 0 9 0 0 24 0
2
0 7 2 6 0 0 0 0 36
2
3 0 18 0 0 28 0 2 0
2
0 0 2 0 0 37 3 0 9
2
8 0 0 10 29 0 0 4 0
2
18 10 0 0 2 0 0 21 0
2
0 0 29 8 0 0 9 5 0
2
28 0 0 0...

output:

888888888888878787848484848484848484828282828282828
777766666666666666666666665555555555555555555555858
777777777777777777777777777777779796969393939393939
666666666676747474747474747272727272727272727272727
555444441111111111111111111111111111111111111111717
5555554444444444444111111191919191919191...

result:

ok Correct!

Test #5:

score: 0
Accepted
time: 42ms
memory: 3592kb

input:

40215
2
5 0 0 2 3 4 5 0 2
2
0 1 4 0 2 4 0 3 7
2
2 0 0 0 0 18 12 0 0
2
0 13 11 0 16 0 0 0 0
2
7 0 6 2 1 0 0 0 5
2
4 0 0 0 0 0 8 2 3
2
5 2 0 0 2 0 2 7 3
2
3 0 0 2 3 4 4 5 0
2
0 0 3 1 0 0 0 12 2
2
2 13 3 0 1 0 0 1 1
2
0 0 10 0 4 0 0 0 18
2
0 1 7 0 0 6 0 0 1
2
3 0 6 3 3 6 0 0 0
2
0 5 0 4 4 1 7 0 0
2
0 0...

output:

777776666555441111919
888666659593939393929
66666666676767676767676767671717
3333333335353525252525252525252525252525
544333333111919191919
88777777771191919
888888877552211191919
777766665554848181818
888888888888433939
533322222222222221819
99995959595939393939393939393939
336363636363629
55544433...

result:

ok Correct!

Test #6:

score: 0
Accepted
time: 23ms
memory: 3820kb

input:

1000
2
346 0 0 0 0 0 325 0 305
2
341 0 0 0 304 0 0 0 325
2
0 315 0 0 0 0 0 335 346
2
299 0 0 0 0 296 325 0 0
2
0 0 324 286 0 298 0 0 0
2
0 0 0 0 0 0 345 323 313
2
0 0 0 0 0 305 0 320 294
2
0 0 0 308 339 0 0 301 0
2
323 0 0 317 0 0 0 0 278
2
0 292 342 0 0 324 0 0 0
2
0 0 0 285 0 342 0 324 0
2
310 0 2...

output:

777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777...

result:

ok Correct!

Test #7:

score: 0
Accepted
time: 23ms
memory: 3816kb

input:

1000
2
232 0 0 223 0 211 0 0 244
2
0 0 0 0 233 277 222 0 252
2
0 250 230 0 0 0 241 0 242
2
248 241 248 0 0 219 0 0 0
2
223 0 0 0 253 240 226 0 0
2
0 0 0 251 0 235 0 239 263
2
267 245 0 220 260 0 0 0 0
2
261 0 0 0 0 256 250 221 0
2
0 240 229 0 0 236 243 0 0
2
0 236 0 248 0 252 242 0 0
2
0 0 239 250 0...

output:

666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666644444444444444444444444444444444444444444444444444444444444444444444444444444444444444444...

result:

ok Correct!

Test #8:

score: 0
Accepted
time: 24ms
memory: 3532kb

input:

1000
2
84 122 93 126 108 97 117 115 115
2
110 100 118 106 104 112 100 118 128
2
107 102 103 109 119 97 93 118 101
2
128 107 106 97 88 90 97 91 97
2
134 122 108 95 103 105 102 95 112
2
88 110 128 99 94 93 105 113 114
2
111 108 118 97 90 99 93 89 115
2
91 98 106 110 111 102 106 96 95
2
110 98 124 110 ...

output:

888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888877777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777766666666666666666666666666666666666666666666666666666666666666666666...

result:

ok Correct!

Test #9:

score: 0
Accepted
time: 19ms
memory: 3824kb

input:

100
2
1076 1058 1108 1113 1118 1160 1056 1150 1094
2
1097 1101 1124 1098 1085 1113 1122 1090 1081
2
1062 1049 1138 1063 1088 1029 1109 1149 1109
2
1005 1079 990 1015 1053 1013 1043 1059 995
2
1041 1043 1079 1092 1040 1079 1104 1057 1016
2
1012 1075 984 1082 1082 993 969 1019 987
2
939 1033 988 1061 ...

output:

888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888...

result:

ok Correct!

Test #10:

score: 0
Accepted
time: 24ms
memory: 3932kb

input:

10
2
10734 10761 10776 10789 10842 10844 10973 10952 10904
2
10639 10677 10586 10820 10717 10667 10636 10594 10659
2
10253 10248 10111 10247 10186 10246 10194 10096 10099
2
10301 10375 10306 10267 9994 10102 10124 10006 10162
2
10894 10878 10645 10624 10493 10697 10843 10738 10719
2
9953 10322 9896 ...

output:

888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888...

result:

ok Correct!

Subtask #3:

score: 0
Wrong Answer

Test #11:

score: 0
Wrong Answer
time: 33ms
memory: 3620kb

input:

26488
21
7 19 0 0 0 0 0 0 0
3
15 21 0 0 0 0 0 0 0
7
4 35 0 0 0 0 0 0 0
5
28 12 0 0 0 0 0 0 0
22
40 3 0 0 0 0 0 0 0
1
7 6 0 0 0 0 0 0 0
5
12 21 0 0 0 0 0 0 0
18
27 13 0 0 0 0 0 0 0
2
36 6 0 0 0 0 0 0 0
15
19 14 0 0 0 0 0 0 0
34
17 20 0 0 0 0 0 0 0
11
17 5 0 0 0 0 0 0 0
19
10 12 0 0 0 0 0 0 0
28
29 9 ...

output:

00000012222222222222222222
222222222222222222211111111111111122
222222222222222222222222222221111222222
2111211121112111211121112111211111112222
0000000000000000000000111111111111111111222
2121212121211
222222222222222221111111111112222
0000000000000000000000011112222222222222
1111111111111111111111...

result:

wrong output format Extra information in the output file

Subtask #4:

score: 0
Skipped

Dependency #1:

0%