QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#565208#9310. Permutation Counting 4oufanCompile Error//Java11876b2024-09-15 20:36:022024-09-15 20:36:02

Judging History

你现在查看的是最新测评结果

  • [2024-09-18 14:56:40]
  • hack成功,自动添加数据
  • (/hack/835)
  • [2024-09-18 14:41:06]
  • hack成功,自动添加数据
  • (/hack/831)
  • [2024-09-17 12:14:52]
  • hack成功,自动添加数据
  • (/hack/825)
  • [2024-09-15 20:36:02]
  • 评测
  • [2024-09-15 20:36:02]
  • 提交

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

Can't find the main class.