QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#875610 | #8805. Pizza Party | Mispertion# | 0 | 736ms | 44668kb | C++23 | 2.2kb | 2025-01-29 23:50:53 | 2025-01-29 23:51:00 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using ll = long long;
#define int ll
using ld = long double;
using pii = pair<int, int>;
#define S second
#define F first
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#define mispertion ios_base::sync_with_stdio(0),cin.tie(0)
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
const ld PI = 3.1415926535;
const ld eps = 1e-9;
const int N = 1e6 + 2;
const int M = 1.5e6 + 13;
ll mod = 1e9+7;
const int infi = 1e18;
const ll infl = 1e16;
const int P = 31;
int mult(int a, int b) {
return a * 1LL * b % mod; }
int sum(int a, int b) {
if(a + b >= mod)
return a + b - mod;
if(a + b < 0)
return a + b + mod;
return a + b;
}
ll binpow(ll a, ll n) {
if (n == 0) return 1;
if (n % 2 == 1) {
return binpow(a, n - 1) * a % (mod);
} else {
ll b = binpow(a, n / 2);
return b * b % (mod);
}
}
int n, a[N], b[N], used[N], ans[N], cur = 0, lst[N], pl[N];
inline void solve() {
cin >> n;
for(int i = 1; i <= n; i++) cin >> a[i];
for(int i = 1; i <= n; i++) cin >> b[i];
for(int i = 1; i <= n; i++){
if(used[b[i]]){
cout << -1 << '\n';
return;
}
used[b[i]] = i;
}
reverse(a + 1, a + n + 1);
for(int i = 1; i <= n; i++){
int bl = -1;
for(int j = 1; j <= cur; j++){
if(used[a[i]] > lst[j]){
if(bl == -1 || lst[bl] < lst[j])
bl = j;
}
}
if(bl == -1){
cur++;
ans[a[i]] = cur;
pl[used[a[i]]] = cur;
lst[cur] = used[a[i]];
}else{
ans[a[i]] = bl;
pl[used[a[i]]] = bl;
lst[bl] = used[a[i]];
}
}
cout << cur << '\n';
for(int i = n; i >= 1; i--)
cout << ans[i] << ' ';
cout << '\n';
for(int i = 1; i <= n; i++)
cout << pl[i] << ' ';
cout << '\n';
}
signed main() {
mispertion;
int t = 1;
//cin >> t;
for(int i = 1; i <= t; i ++){
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 55ms
memory: 20788kb
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:
-1
result:
wrong answer jury uses fewer stacks: jans = 2, pans = 1061109567
Subtask #2:
score: 0
Wrong Answer
Test #24:
score: 0
Wrong Answer
time: 2ms
memory: 10000kb
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 12 47 50 25 19 58 34 60 83 48 84 107 124 43 42 106 106 39 67 71 34 36 55 73 47 1 72 22 84 69 50 99 66 38 9 42 54 9 53 83 55 65 33 62 31 31 66 38 23 93 41 96 19 75 52 73 23 110 58 57 43 26 53 7 79 72 38 37 32 111 46 71 15 89 105 86 67 49 110 78 46 69 80 75 38 41 58 39 34 101 77 30 111 86 60 75 79...
result:
wrong output format Expected EOLN
Subtask #3:
score: 0
Wrong Answer
Test #39:
score: 0
Wrong Answer
time: 736ms
memory: 44668kb
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 892 1583 1127 1033 1152 608 1193 832 1059 1452 914 1745 1446 1202 1039 972 512 1080 1226 1908 1142 1327 1142 1545 777 1476 662 866 1330 697 621 1625 397 987 533 1753 646 1586 1019 993 1041 1757 945 728 1173 915 567 1131 1102 1458 436 486 580 422 482 1328 350 466 1425 712 1515 461 210 1419 852 8...
result:
wrong output format Expected EOLN