QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#249713 | #2264. Secrets of Legendary Treasure | sharaelong# | RE | 1ms | 3528kb | C++17 | 1.4kb | 2023-11-12 14:31:02 | 2023-11-12 14:31:02 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, pll> plll;
#define fi first
#define se second
const int INF = (int)1e9+5;
const ll LLINF = (ll)1e18+5;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n, m; cin >> n >> m;
set<int> S;
for(int i = 1; i <= n+m; i++) S.insert(i);
vector<int> A(n), B(m);
for(auto &i : A) {
cin >> i;
if(i) S.erase(i);
}
for(auto &i : B) {
cin >> i;
if(i) S.erase(i);
}
int a = 0, b = 0;
while(a < n || b < m) {
int c = *S.begin();
while(a < n && A[a]) a++;
while(b < m && B[b]) b++;
int x = a, y = b;
while(x < n && A[x] == 0) x++;
while(y < m && B[y] == 0) y++;
if((a && A[a-1] > c) || (b && B[b-1] > c)) {
if(!b) B[b] = c;
else if(!a || A[a-1] < B[b-1]) A[a] = c;
else B[b] = c;
} else {
if(a == n) B[b] = c;
else if(b == m) A[a] = c;
else if(x == n) B[b] = c;
else if(y == m || A[x] < B[y]) A[a] = c;
else B[b] = c;
}
S.erase(c);
}
for(auto i : A) cout << i << " ";
cout << "\n";
for(auto i : B) cout << i << " ";
cout << "\n";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3472kb
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: 3528kb
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...