QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#244007#2264. Secrets of Legendary TreasureNYCU_gAwr_gurA#RE 0ms3596kbC++171.5kb2023-11-08 20:19:022023-11-08 20:19:03

Judging History

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

  • [2023-11-08 20:19:03]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:3596kb
  • [2023-11-08 20:19:02]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#ifdef DEBUG
#define fast
#else
#define fast cin.tie(0)->sync_with_stdio(0)
#define cerr if(1);else cerr
#define endl '\n'
#endif
#define _ <<' '<<
#define ALL(v) v.begin(),v.end()
#define ft first
#define sd second

using ll = long long;
using ld = long double;
using pii = pair<int,int>;

signed main() {
    fast;

    int n, m;
    cin >> n >> m;
    vector<int> arr(n), brr(m), used(n+m+1, false);
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
        used[arr[i]] = true;
    }
    for (int i = 0; i < m; ++i) {
        cin >> brr[i];
        used[brr[i]] = true;
    }

    int i = 0, j = 0, k = 1;
    while (i < n || j < m) {
        while(i < n && arr[i] != 0) ++i;
        while(j < m && brr[j] != 0) ++j;
        if (i >= n && j >= m) break;
        while(k <= n + m && used[k]) ++k;

        int ii = 0, jj = 0;
        for (int p = i; p < n; ++p) if (arr[p] && !ii) ii = arr[p];
        for (int p = j; p < m; ++p) if (brr[p] && !jj) jj = brr[p];

        int li = 0, lj = 0;
        if (i) li = arr[i-1];
        if (j) lj = brr[j-1];

        //cout << k _ li << ' ' << lj << ' ' << ii << ' ' << jj << endl;

        if (li < k && lj < k) {
            if (ii < jj) arr[i++] = k++;
            else brr[j++] = k++;
        } else if (li < k) {
            arr[i++] = k++;
        } else {
            brr[j++] = k++;
        }
    }
    
    for (int &x : arr) cout << x << ' ';
    cout << '\n';
    for (int &x : brr) cout << x << ' ';
    cout << '\n';

    cerr _ "meow" _ endl;

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 3596kb

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: -100
Runtime Error

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:


result: