# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1055790 |
2024-08-13T05:28:21 Z |
변재우(#11070) |
Pizza Party (CCO24_day1problem2) |
C++17 |
|
325 ms |
28752 KB |
#include <bits/stdc++.h>
using namespace std;
const int Nmax=1000010;
int N, K, A[Nmax], V[Nmax], X[Nmax], Y[Nmax], I[Nmax];
set<pair<int, int>> S;
signed main() {
ios_base::sync_with_stdio(0); cin.tie(0);
cin>>N;
for(int i=1; i<=N; i++) {
int x; cin>>x, V[x]=i;
}
for(int i=1; i<=N; i++) cin>>A[i], A[i]=V[A[i]];
for(int i=1; i<=N; i++) I[A[i]]=i;
for(int i=1; i<=N; i++) if(A[i]==A[i-1]) {
cout<<-1; return 0;
}
for(int i=1; i<=N; i++) {
auto p=S.lower_bound(make_pair(A[i], 0));
if(p==S.end()) X[i]=++K, S.insert({A[i], K});
else {
X[i]=(*p).second;
S.erase(p), S.insert({A[i], X[i]});
}
Y[I[i]]=X[i];
}
cout<<K<<"\n";
for(int i=1; i<=N; i++) cout<<X[i]<<" \n"[i==N];
for(int i=1; i<=N; i++) cout<<Y[i]<<" \n"[i==N];
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
51 ms |
4176 KB |
jury uses fewer stacks: jans = 2, pans = 1061109567 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
616 KB |
flavours don't match |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
325 ms |
28752 KB |
flavours don't match |
2 |
Halted |
0 ms |
0 KB |
- |