QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#184090#5604. Triangle ContainmentzhoujiuWA 1ms3460kbC++201.3kb2023-09-20 12:14:122023-09-20 12:14:12

Judging History

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

  • [2023-09-20 12:14:12]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3460kb
  • [2023-09-20 12:14:12]
  • 提交

answer

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

const int N=1e5+10;

struct Point
{
	int id,val;
	int x,y;
};

int n,m;
int tr[N],idx[N];

int lowbit(int x){return x&-x;}

int sum(int x)
{
	int res=0;
	for(int i=x;i;i-=lowbit(i)) res+=tr[i];
	return res;
}

void add(int x,int v)
{
	for(int i=x;i<=n;i+=lowbit(i)) tr[i]+=v;
}

int Cross(Point A,Point B){return A.y*B.x-A.x*B.y;}
int dis(Point A,Point B){return (A.x-B.x)*(A.x-B.x)+(A.y-B.y)*(A.y-B.y);}

bool cmp(Point A,Point B)
{
	return Cross(A,B)<0;
}

signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);

	cin>>n>>m;

	vector<Point> q,p;
	for(int i=1;i<=n;i++)
	{
		int x,y,v;
		cin>>x>>y>>v;

		q.push_back({i,v,x,y});
		p.push_back({i,v,x-m,y});
	}

	sort(q.begin(),q.end(),cmp);

	sort(p.begin(),p.end(),cmp);

	for(int i=1;i<=n;i++) idx[p[i-1].id]=i;

	// for(int i=0;i<q.size();i++)
	// 	cout<<q[i].id<<' ';
	// cout<<endl;

	// for(int i=0;i<p.size();i++)
	// 	cout<<p[i].id<<' ';
	// cout<<endl;

	vector<int> ans(n);
	int cur=0;
	for(int i=0;i<n;i++)
	{
		int pos=q[i].id;
		ans[i]=cur-sum(idx[pos]);
		add(idx[pos],q[i].val);
		cur+=q[i].val;
	}

	for(int i=0;i<n;i++)
		cout<<ans[i]<<'\n';

	return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3460kb

input:

5 8
-8 1 1
-1 10 2
0 3 4
7 1 8
8 2 16

output:

0
8
0
12
0

result:

wrong answer 2nd lines differ - expected: '12', found: '8'