QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#568496#9310. Permutation Counting 4ShirasuAzusaWA 0ms3580kbC++14851b2024-09-16 16:46:112024-09-16 16:46:12

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-16 16:46:12]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3580kb
  • [2024-09-16 16:46:11]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        // Initialize difference array with n+2 elements
        // Using vector<int> for flexibility and automatic memory management
        vector<int> diff(n + 2, 0);
        for(int i=0;i<n;i++){
            int l, r;
            cin >> l >> r;
            diff[l] +=1;
            if(r+1 <= n){
                diff[r+1] -=1;
            }
        }
        bool possible = true;
        long long c =0;
        for(int k=1; k<=n; k++){
            c += diff[k];
            if(c < k){
                possible = false;
                break;
            }
        }
        cout << (possible ? "1" : "0") << "\n";
    }
}

詳細信息

Test #1:

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

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

result:

wrong answer 2nd words differ - expected: '1', found: '0'