# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1055796 |
2024-08-13T05:33:52 Z |
변재우(#11070) |
Pizza Party (CCO24_day1problem2) |
C++17 |
|
305 ms |
24136 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[A[i]]=++K, S.insert({A[i], K});
else {
X[A[i]]=(*p).second;
S.erase(p), S.insert({A[i], X[i]});
}
Y[i]=X[A[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 |
53 ms |
4168 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 |
600 KB |
Integer element c_i[2] equals to 0, violates the range [1, 134] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
305 ms |
24136 KB |
Integer element c_i[1] equals to 0, violates the range [1, 1996] |
2 |
Halted |
0 ms |
0 KB |
- |