QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#568496 | #9310. Permutation Counting 4 | ShirasuAzusa | WA | 0ms | 3580kb | C++14 | 851b | 2024-09-16 16:46:11 | 2024-09-16 16:46:12 |
Judging History
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'