QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#565215 | #9310. Permutation Counting 4 | oufan | WA | 3ms | 34880kb | C++20 | 874b | 2024-09-15 20:37:19 | 2024-09-15 20:37:20 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
int n;
priority_queue<int, vector<int>, greater<int>> q[N];
signed main()
{
ios::sync_with_stdio(false), cin.tie(nullptr);
cin >> n;
for (int i = 1;i <= n;i++)
{
int x, y;cin >> x >> y;
q[x].emplace(y);
}
for (int i = 1;i <= n;i++)
{
while (!q[i].empty() && q[i].top() < i) q[i].pop();
if (q[i].empty())
{
cout << "0" << endl;
return 0;
}
if (q[i].size() == 1)
{
continue;
}
int x = q[i].top() + 1;q[i].pop();
if (q[x].size() < q[i].size()) swap(q[i], q[x]);
while (!q[i].empty())
{
q[x].emplace(q[i].top());
q[i].pop();
}
}
cout << "1" << endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 3ms
memory: 34880kb
input:
4 5 1 2 1 5 1 2 1 2 2 2 5 1 1 2 4 2 3 5 5 3 4 5 3 5 1 2 3 4 3 5 3 3 5 1 5 1 4 4 5 5 5 1 2
output:
0
result:
wrong answer Unexpected EOF in the participants output