QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#574726#9310. Permutation Counting 4495684945WA 0ms3628kbC++20899b2024-09-19 00:06:542024-09-19 00:06:55

Judging History

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

  • [2024-09-19 00:06:55]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3628kb
  • [2024-09-19 00:06:54]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> PII;

void solve() {
    int n;
    cin >> n;
    vector<vector<int>> intervals(n + 1);
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        intervals[x].push_back(y);
    }

    priority_queue<int, vector<int>, greater<int>> pq;
    for (int i = 1; i <= n; i++) {
        for (int y : intervals[i]) {
            pq.push(y);
        }

        if (pq.empty()) {
            cout << 0 << endl;
            return;
        }

        int y = pq.top();
        pq.pop();

        if (y < i) {
            cout << 0 << endl;
            return;
        }
    }
    cout << 1 << endl;
}

signed main() {
    int t;
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> t;
    while (t--) solve();
    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3628kb

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
1
0
1

result:

wrong answer 4th words differ - expected: '0', found: '1'