QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#875682 | #8805. Pizza Party | woohyun_jng | 0 | 448ms | 128116kb | C++23 | 1.4kb | 2025-01-30 02:53:45 | 2025-01-30 02:53:47 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
#define MAX 1500000
using namespace std;
typedef array<int, 2> pr;
int A[MAX], B[MAX], cnt[2][MAX], X[MAX], ans[2][MAX];
vector<int> arr[MAX];
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int N, V;
set<pr> st;
set<pr>::iterator iter;
bool flag = true;
cin >> N;
for (int i = N; i >= 1; i--)
cin >> A[i], cnt[0][A[i]]++;
for (int i = 1; i <= N; i++)
cin >> B[i], cnt[1][B[i]]++;
for (int i = 1; i <= N; i++)
flag &= cnt[0][i] == cnt[1][i];
if (!flag) {
cout << -1 << '\n';
return 0;
}
for (int i = 1; i <= N; i++)
arr[A[i]].push_back(i);
for (int i = 1; i <= N; i++)
reverse(arr[i].begin(), arr[i].end());
for (int i = 1; i <= N; i++)
X[i] = arr[B[i]].back(), arr[B[i]].pop_back();
for (int i = 1; i <= N; i++) {
if (st.empty() || (*st.begin())[0] > X[i])
V = st.size() + 1;
else
iter = prev(st.lower_bound({X[i], 0})), V = (*iter)[1], st.erase(iter);
ans[0][X[i]] = ans[1][i] = V;
st.insert({X[i], V});
}
cout << st.size() << '\n';
for (int i = N; i >= 1; i--)
cout << ans[0][i] << ' ';
cout << '\n';
for (int i = 1; i <= N; i++)
cout << ans[1][i] << ' ';
cout << '\n';
return 0;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 152ms
memory: 67168kb
input:
1000000 1 1 1 2 1 1 1 1 1 2 1 1 1 2 1 2 1 1 1 2 2 1 2 1 2 2 2 2 2 1 2 2 1 1 1 2 1 1 2 1 2 2 2 2 2 2 2 1 2 1 2 2 1 1 2 1 2 2 2 1 1 2 2 1 1 1 1 2 1 2 2 1 2 2 2 1 2 1 1 2 1 1 1 2 1 2 2 1 1 1 2 2 2 2 1 2 1 1 1 2 2 2 1 1 1 1 1 2 2 2 1 1 1 2 2 2 2 1 2 2 2 1 2 1 1 1 1 1 2 2 2 2 1 1 1 1 2 2 2 2 1 2 1 1 2 1 ...
output:
2 1 1 1 2 1 1 1 1 1 2 1 1 1 2 1 2 1 1 1 2 2 1 2 1 2 2 2 2 2 1 2 2 1 1 1 2 1 1 2 1 1 1 1 1 1 1 1 2 1 2 1 1 2 2 1 2 1 1 1 2 2 1 1 2 2 2 2 1 2 1 1 2 1 1 1 2 1 2 2 1 2 2 2 1 2 1 1 2 2 2 1 1 1 1 2 1 2 2 2 1 1 1 2 2 2 2 2 1 1 1 2 2 1 1 1 1 1 2 1 1 1 2 1 2 2 2 2 2 1 1 1 1 2 2 2 2 1 1 1 1 2 1 2 2 1 2 1 2 1 ...
result:
wrong output format Expected EOLN
Subtask #2:
score: 0
Wrong Answer
Test #24:
score: 0
Wrong Answer
time: 2ms
memory: 18420kb
input:
5000 3140 3541 3540 3884 2792 3966 1359 549 2273 2669 2100 4448 4722 3937 23 3964 4910 3490 61 2723 2554 4177 3025 4909 2127 939 2536 835 2801 459 3374 972 4687 2102 2919 4367 4905 3414 869 2272 507 4210 2906 2584 1639 2020 3287 3447 2500 4866 3284 2010 1826 331 1873 3895 4946 889 3059 894 4233 2541...
output:
134 1 1 2 2 1 3 3 3 4 5 1 6 5 2 6 7 7 4 3 3 3 7 8 9 6 10 2 7 10 3 9 4 4 3 10 5 8 6 4 7 3 4 8 9 6 5 7 11 8 10 9 9 10 11 12 5 12 9 10 7 3 6 9 7 10 6 11 13 12 7 12 13 13 8 14 12 15 16 10 15 17 11 1 5 8 9 10 17 16 11 15 10 10 3 3 16 4 17 18 11 16 15 12 11 8 7 13 12 11 12 13 9 12 13 4 17 14 6 14 6 17 15 ...
result:
wrong output format Expected EOLN
Subtask #3:
score: 0
Wrong Answer
Test #39:
score: 0
Wrong Answer
time: 448ms
memory: 128116kb
input:
1000000 134990 280863 995875 82485 490673 517020 49269 636214 69331 626226 96180 743288 524606 324456 937362 164072 680663 931183 195920 618400 741187 164410 478750 590824 160168 192530 154228 661164 17160 343556 653139 229351 350929 719054 634472 433811 352199 163260 833268 56711 963125 346135 9350...
output:
1996 1 2 3 3 3 4 4 4 5 6 7 8 7 2 7 8 8 8 1 9 5 9 6 5 7 6 8 8 3 4 10 5 11 2 6 7 5 12 6 13 7 10 8 10 9 8 10 14 14 11 14 9 9 5 5 15 12 13 5 15 10 15 10 16 14 15 16 13 13 8 2 4 17 3 18 3 19 8 11 16 18 11 8 19 14 20 14 20 6 7 15 14 5 7 21 12 16 15 6 9 15 15 17 12 13 16 17 18 14 5 7 3 6 10 8 11 9 12 12 3 ...
result:
wrong output format Expected EOLN