QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#574528#9310. Permutation Counting 4495684945WA 0ms3596kbC++20820b2024-09-18 22:35:062024-09-18 22:35:06

Judging History

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

  • [2024-09-18 22:35:06]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3596kb
  • [2024-09-18 22:35:06]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define inf 0x3f3f3f3f3f3f3f3f
typedef pair<int,int> PII;
void solve(){
	int n;
	cin>>n;
	priority_queue<PII,vector<PII>,greater<PII>>q;
	for(int i=1,x,y;i<=n;i++){
		cin>>x>>y;
		q.push({x,y});
	}
	vector<PII>ans;
	for(int i=1;i<=n;i++){
		int x,y=-1;
		if(q.size()==0){
			cout<<0<<endl;
			return ;
		}
		while(q.size()&&(y<i)){
			x=q.top().first;
			y=q.top().second;
			q.pop();
			if(x>i){
				cout<<0<<endl;
				return ;
			}
		}
		ans.push_back({i,y});
	}
	int p=1;
	for(auto [x,y]:ans){
		if(p>=x&&p<=y){
			p=x+1;
		}else{
			cout<<0<<endl;
			return ;
		}
	}
	cout<<1<<endl;
}
signed main(){
	int t=1;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: 3596kb

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'