QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#501276#2264. Secrets of Legendary Treasureyzkkai#WA 0ms3552kbC++202.5kb2024-08-02 16:18:112024-08-02 16:18:12

Judging History

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

  • [2024-08-02 16:18:12]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3552kb
  • [2024-08-02 16:18:11]
  • 提交

answer

#include <bits/stdc++.h>
#define sz(x) signed(size(x))
using namespace std;
using ll = long long;
using LL = long long;
#define si(x) (int)x.size()
#define F first
#define S second
inline void solve() {
    int n, m;
    cin >> n >> m;
    
    vector<bool> vis(n + m + 1);
    vector<int> a(n), b(m);
    for (int i = 0; i < n; i++) cin >> a[i], vis[a[i]] = 1;
    for (int i = 0; i < m; i++) cin >> b[i], vis[b[i]] = 1;
    
    int mx1 = *max_element(a.begin(), a.end());
    int mx2 = *max_element(b.begin(), b.end());
    
    if (mx1 > mx2) a.push_back(1e9 + 1), b.push_back(1e9);
    else a.push_back(1e9), b.push_back(1e9 + 1);
    
    queue<int> q;
    for (int i = 1; i <= n + m; i++) {
        if (vis[i]) continue;
        q.push(i);
    }

    vector<pair<int, int>> c, d;
    int cur = 0;
    for (int i = 0; i <= n; i++) {
        if (a[i] == 0) cur++;
        else {
            c.push_back({a[i], cur});
            cur = 0;
        }
    }
    for (int i = 0; i <= m; i++) {
        if (b[i] == 0) cur++;
        else {
            d.push_back({b[i], cur});
            cur = 0;
        }
    }
    cerr << si(c) << ' ' << si(d) << '\n';

    vector<int> res1, res2;
    int i = 0, j = 0;
    while (i < si(c) && j < si(d) && si(q)) {
        if (c[i].F > d[j].F) {
            while (j && q.front() < d[j - 1].F) {
                res1.push_back(q.front());
                q.pop();
                c[i].S--;
                if (c[i].S == 0) i++;
            }
            for (int k = 0; k < d[j].S; k++) {
                res2.push_back(q.front());
                q.pop();
            }
            res2.push_back(d[j].F);
            j++;
        } else { 
            while (i && q.front() < c[i - 1].F) {
                res1.push_back(q.front());
                q.pop();
                d[j].S--;
                if (d[j].S == 0) j++;
            }
            for (int k = 0; k < c[i].S; k++) {
                res1.push_back(q.front());
                q.pop();
            }
            res1.push_back(c[i].F);
            i++;
        }
    }
    while (si(q)) {
        int cur = q.front();
        q.pop();
        if (i < si(c)) res1.push_back(cur);
        else res2.push_back(cur);
    }
    for (auto x : res1) if (x < 1e9) cout << x << ' ';
    cout << '\n';

    for (auto x : res2) if (x < 1e9) cout << x << ' ';
    cout << '\n';

}

signed main() {
    cin.tie(0)->sync_with_stdio(0);
    int t = 1;
    while (t--)
        solve();
    return 0;
}

詳細信息

Test #1:

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

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:




result:

wrong output format Unexpected end of file - int32 expected