# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1055880 |
2024-08-13T06:15:28 Z |
4321(#11112) |
Pizza Party (CCO24_day1problem2) |
C++17 |
|
652 ms |
71808 KB |
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf = 1e9;
const ll INF = 1e18;
int n;
vector<int> g[1000010];
int a[1000010];
int b[1000010];
int main() {
fast;
cin >> n;
for(int i=1; i<=n; i++) {
int x;
cin >> x;
g[x].eb(i);
}
set<pii> S;
for(int i=1; i<=n; i++) {
int x;
cin >> x;
if(g[x].empty()) {
cout << -1;
return 0;
}
int y = g[x].back();
g[x].pop_back();
auto it = S.lower_bound(mp(y, 0));
int c = S.size()+1;
if(it != S.end()) {
c = it->se;
S.erase(it);
}
a[y] = b[i] = c;
S.insert(mp(y, c));
}
cout << S.size() << "\n";
for(int i=1; i<=n; i++) cout << a[i] << " ";
cout << "\n";
cout << b[1];
for(int i=2; i<=n; i++) cout << " " << b[i];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
164 ms |
39852 KB |
Expected EOLN |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
24152 KB |
Expected EOLN |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
652 ms |
71808 KB |
Expected EOLN |
2 |
Halted |
0 ms |
0 KB |
- |