QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#251552#2264. Secrets of Legendary Treasurelemonilemon#WA 1ms3420kbC++171.6kb2023-11-14 20:35:352023-11-14 20:35:36

Judging History

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

  • [2023-11-14 20:35:36]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3420kb
  • [2023-11-14 20:35:35]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using uint = unsigned int;
const double EPS = 1e-8;
const int INF = 0x3F3F3F3F;
const ll LINF = 46 * ll(1e17);
const int MOD = 1e9 + 7;
const int maxn = 1e5 + 25;

signed main() { ios::sync_with_stdio(0); cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> a, b;
    vector<int> has(n + m + 1);
    for (int i = 0, x; i < n; i++) {
        cin >> x;
        if (x) {
            has[x] = 1;
            a.push_back({x, i});
        }
    }
    for (int i = 0, x; i < m; i++) {
        cin >> x;
        if (x) {
            has[x] = 1;
            b.push_back({x, i});
        }
    }
    a.push_back({INF, n});
    b.push_back({INF, m});

    vector<int> ans_a, ans_b;
    size_t it_a = 0, it_b = 0, it = 1;
    auto get = [&] () {
        while (has[it])
            it++;
        has[it] = true;
        return it;
    };
    while (it_a < a.size() || it_b < b.size()) {
        if (it_b == b.size() || (it_a < a.size() && a[it_a].first < b[it_b].first)) {
            while (ans_a.size() < a[it_a].second)
                ans_a.push_back(get());
            ans_a.push_back(a[it_a].first);
            it_a++;
        }
        else {
            while (ans_b.size() < b[it_b].second)
                ans_b.push_back(get());
            ans_b.push_back(b[it_b].first);
            it_b++;
        }
    }
    ans_a.resize(n);
    ans_b.resize(m);
    for (int a : ans_a)
        cout << a << ' ';
    cout << '\n';
    for (int b : ans_b)
        cout << b << ' ';
    cout << '\n';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3420kb

input:

100 100
1 2 3 4 6 10 11 14 17 18 19 21 24 25 26 27 29 32 34 35 36 37 39 40 44 49 52 53 55 59 65 66 67 68 73 74 81 82 83 85 86 88 89 90 96 98 99 102 103 104 106 107 108 116 117 118 121 124 127 128 129 130 131 132 134 137 138 139 141 145 148 149 152 153 154 156 157 158 161 162 163 167 169 170 173 174 ...

output:

1 2 3 4 6 10 11 14 17 18 19 21 24 25 26 27 29 32 34 35 36 37 39 40 44 49 52 53 55 59 65 66 67 68 73 74 81 82 83 85 86 88 89 90 96 98 99 102 103 104 106 107 108 116 117 118 121 124 127 128 129 130 131 132 134 137 138 139 141 145 148 149 152 153 154 156 157 158 161 162 163 167 169 170 173 174 175 177 ...

result:

ok correct

Test #2:

score: 0
Accepted
time: 0ms
memory: 3392kb

input:

99 1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
37

output:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 
37 

result:

ok correct

Test #3:

score: 0
Accepted
time: 1ms
memory: 3380kb

input:

90 96
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 92
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

output:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 92 
90 91 93 94 95 96 97 98 99 100 101 102...

result:

ok correct

Test #4:

score: 0
Accepted
time: 0ms
memory: 3396kb

input:

97 83
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

83 84 85 86 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 ...

result:

ok correct

Test #5:

score: -100
Wrong Answer
time: 0ms
memory: 3408kb

input:

92 90
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
89 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

output:

91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 1...

result:

wrong answer B is not sorted.