# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1055797 |
2024-08-13T05:35:08 Z |
변재우(#11070) |
Pizza Party (CCO24_day1problem2) |
C++17 |
|
349 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[A[i]]=++K, S.insert({A[i], K});
else {
X[A[i]]=(*p).second;
S.erase(p), S.insert({A[i], X[A[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 |
52 ms |
4176 KB |
jury uses fewer stacks: jans = 2, pans = 1061109567 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
600 KB |
good job! |
2 |
Incorrect |
1 ms |
604 KB |
Integer element c_i[3706] equals to 0, violates the range [1, 136] |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
332 ms |
28744 KB |
good job! |
2 |
Incorrect |
349 ms |
28752 KB |
Integer element c_i[505065] equals to 0, violates the range [1, 1978] |
3 |
Halted |
0 ms |
0 KB |
- |