QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#124000#87. Devil's ShareQwerty123213 1184ms3452kbC++17995b2023-07-14 02:54:062023-07-14 02:54:06

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-14 02:54:06]
  • 评测
  • 测评结果:13
  • 用时:1184ms
  • 内存:3452kb
  • [2023-07-14 02:54:06]
  • 提交

answer

#include <bits/stdc++.h>

constexpr int D = 9;

void solve() {
    int k;
    std::cin >> k;
    std::array<int, D> ar;
    for (auto& i : ar) {
        std::cin >> i;
    }
    std::vector<int> vec;
    for (int i = 0; i < D; i++) {
        vec.insert(vec.end(), ar[i], i + 1);
    }
    std::pair<std::string, std::string> ans(std::string(1, 10), "");
    do {
        std::string s(vec.begin(), vec.end());
        std::string max;
        for (int i = 0; i < s.size() - k + 1; i++) {
            max = std::max(max, s.substr(i, k));
        }
        ans = std::min(ans, {max, s});

    } while (std::next_permutation(vec.begin(), vec.end()));

    for (auto& ch : ans.second) {
        ch += '0';
    }
    std::cout << ans.second << "\n";
    // std::cout.flush();
}

int32_t main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int t;
    std::cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 13
Accepted

Test #1:

score: 13
Accepted
time: 1184ms
memory: 3452kb

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:

3112344
12233341414
241244
312312344
1112223344
22133
23341144
2122333
1344
31312444
2121244
31131223444
212134
2122133
12223444
13444
12223334
13341144
2313132244
12342424
122233
211444
11223
11223344
11222334
13
223131314
323244
2323234
11334
3123123444
114
122233414
11333
12234
222334
3111444
144...

result:

ok Correct!

Subtask #2:

score: 0
Time Limit Exceeded

Test #2:

score: 0
Time Limit Exceeded

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:


result:


Subtask #3:

score: 0
Time Limit Exceeded

Test #11:

score: 0
Time Limit Exceeded

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:


result:


Subtask #4:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%