QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#144710#4188. Excursion to Porvoovalue0WA 2ms6820kbC++201.4kb2023-08-21 17:58:282023-08-21 17:58:32

Judging History

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

  • [2023-08-21 17:58:32]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:6820kb
  • [2023-08-21 17:58:28]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e5 + 10;
#define fi first
#define se second
typedef pair<int,int> pii;
typedef pair<int,pair<int,int>> piii;
int n,m; 
priority_queue<piii,vector<piii>,greater<piii>> heap;
priority_queue<pii,vector<pii>,greater<pii>> q[N];
int main()
{
	scanf("%d %d",&n,&m);
	for(int i= 1;i<=m;i++)
	{
		int a,b,c;
		scanf("%d %d %d",&a,&b,&c);
		heap.push({c,{a,i}});
		q[a].push({b,i});
	}
	int k;
	int l = 0;
	int r = 0;
	int res = 0;
	vector<pii> v;
	for(int i = 1;i<n;i++)
	{
		res += q[i].top().fi;
	}
	v.push_back({heap.top().fi,res});
	while(heap.size())
	{
		r = heap.top().fi;
		while(heap.size() && heap.top().fi == r)
		{
			auto t = heap.top();
			int i = t.se.fi;
			int idx = t.se.se;	
			while(q[i].size() && q[i].top().se == idx)
			{
				res -= q[i].top().fi;
				q[i].pop();
				res += q[i].top().fi;
			}
			heap.pop();
		}
		if(heap.empty())
		{
			break;
		}
		auto t = heap.top();
		r = t.fi;
		v.push_back({r,res});
	}
	scanf("%d",&k);
	
	while(k--)
	{
		int x;
		scanf("%d",&x);
		pii s = {x,0};
		auto idx = lower_bound(v.begin(),v.end(),s) - v.begin();
		cout<<idx<<' ';
		if(idx >= v.size())
		{
			puts("impossible");
		}
		else
		{
			printf("%d\n",v[idx].fi);
		}
	}
//	for(auto x : v)
//	{
//		cout<<x.fi<<' '<<x.se<<endl;
//	}
	return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 6820kb

input:

2 2
1 100 300
1 1 30
5
400
500
300
20
1

output:

2 impossible
2 impossible
1 300
0 30
0 30

result:

wrong answer 1st lines differ - expected: 'impossible', found: '2 impossible'