QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#184090 | #5604. Triangle Containment | zhoujiu | WA | 1ms | 3460kb | C++20 | 1.3kb | 2023-09-20 12:14:12 | 2023-09-20 12:14:12 |
Judging History
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'