QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#93908 | #4422. Two Permutations | Tobo# | WA | 855ms | 23364kb | C++20 | 1.4kb | 2023-04-03 20:15:37 | 2023-04-03 20:15:40 |
Judging History
answer
#include <bits/stdc++.h>
#define N 300005
#define mod 998244353
using i64 = long long;
using namespace std;
int n, a[N], b[N], c[N << 1], s[N];
int lowbit(int x) { return x & -x; }
void add(int x, int y)
{
while (x <= n)
{
s[x] += y;
x += lowbit(x);
}
}
int query(int x)
{
int res = 0;
while (x)
{
res += s[x];
x -= lowbit(x);
}
return res;
}
void solve()
{
cin >> n;
fill(s + 1, s + n + 1, 0);
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 * 2; i++)
cin >> c[i];
int ans = 1, pre = 1;
set<int> s;
for (int i = 1; i <= n * 2; i++)
{
if (!s.count(c[i]))
{
if (query(c[i] - 1) < c[i] - 1)
{
cout << 0 << '\n';
return;
}
if (query(c[i] - 1) == (c[i] - 1) * 2)
ans = ans * 2 % mod;
s.insert(c[i]);
}
else
{
if (query(c[i] - 1) != 2 * c[i] - 2)
{
cout << 0 << '\n';
return;
}
}
add(c[i], 1);
}
cout << ans << '\n';
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
cin >> t;
while (t--)
solve();
}
详细
Test #1:
score: 0
Wrong Answer
time: 855ms
memory: 23364kb
input:
282 1000 434 697 735 906 614 835 227 800 116 98 776 601 110 371 262 452 608 368 719 717 241 572 203 410 440 749 604 457 516 637 488 691 841 493 418 307 745 499 833 789 819 179 357 288 129 954 29 391 80 389 771 613 653 747 928 570 518 1000 547 587 727 778 669 554 426 899 256 681 515 532 409 677 533 3...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
wrong answer 1st lines differ - expected: '4', found: '0'