QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#659503 | #9487. Vivid Colors | ucup-team3510# | WA | 2ms | 7768kb | C++14 | 1.8kb | 2024-10-19 20:27:27 | 2024-10-19 20:27:28 |
Judging History
answer
#include<iostream>
#include<algorithm>
using namespace std;
const int mod=998244353;
inline int qpow(int a,int b)
{
int ret=1;
while(b)
{
if(b&1)
{
ret=(long long)
ret*a%mod;
}
a=(long long)
a*a%mod,b>>=1;
}
return ret;
}
int n;
struct point
{
int x,y,z;
};
inline bool operator <(const point &a,const point &b)
{
return a.x==b.x?a.y<b.y:a.x>b.x;
}
point a[2010];
struct frac
{
int a,b,x,y,z;
};
inline bool operator <(const frac &a,const frac &b)
{
return (long long)a.a*b.b<(long long)b.a*a.b;
}
int num=0,p[2010];
frac f[2000010];
int sx[2010],sy[2010];
long long ans[2010];
inline long long calc(int x,int y)
{
return (long long)x*x+
(long long)y*y+(long long)x*y;
}
int main()
{
cin>>n;
for(int i=1,X,Y,Z;i<=n;i++)
{
cin>>X>>Y>>Z;
a[i]={Y-X,Z-Y,X-Z};
}
sort(a+1,a+n+1);
for(int i=n;i;i--)
{
for(int j=i-1;j;j--)
{
if(a[i].x==a[j].x)
{
continue;
}
f[++num]={a[j].y-a[i].y,
a[i].x-a[j].x,j,i};
}
}
sort(f+1,f+num+1);
for(int i=1;i<=n;i++)
{
p[i]=i;
sx[i]=sx[i-1]+a[i].x;
sy[i]=sy[i-1]+a[i].y;
}
for(int i=0;i<=n;i++)
{
ans[i]=max(ans[i],
calc(sx[i],sy[i]));
ans[n-i]=max(ans[n-i],
calc(sx[n]-sx[i],sy[n]-sy[i]));
}
for(int i=1;i<=num;i++)
{
int x=f[i].z=p[f[i].x];
sx[x]+=a[f[i].y].x-a[f[i].x].x;
sy[x]+=a[f[i].y].y-a[f[i].x].y;
if(i==num||f[i]<f[i+1])
{
for(int j=i;j;j--)
{
if(f[j]<f[i])
{
break;
}
int x=f[j].z;
ans[x]=max(ans[x],calc(sx[x],sy[x]));
ans[n-x]=max(ans[n-x],calc(sx[n]-sx[x],sy[n]-sy[x]));
}
}
p[f[i].x]++,p[f[i].y]--;
}
int p=2*qpow(9,mod-2)%mod;
for(int i=1;i<=n;i++)
{
cout<<ans[i]%mod*p%mod
*qpow(i*i,mod-2)%mod<<'\n';
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3572kb
input:
3 180 0 0 0 180 180 0 0 180
output:
7200 5400 800
result:
ok 3 tokens
Test #2:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
6 30594 32322 46262 63608 59020 98436 90150 32740 67209 82886 4627 54813 3112 67989 74995 60872 9967 9051
output:
715162883 838096208 930330061 405079896 880764907 526006962
result:
ok 6 tokens
Test #3:
score: -100
Wrong Answer
time: 2ms
memory: 7768kb
input:
144 41472 41434 41317 16965 16900 17440 65702 65688 65497 15829 15900 15359 186620 186555 186425 22130 22030 22145 22995 23022 23320 54430 54525 54770 145816 145739 146046 106008 106083 106073 84481 84531 84306 162468 162563 162313 144375 144342 144210 68596 68548 68201 124014 124100 123649 137878 1...
output:
665561664 166436731 579289313 596235635 328369026 523827415 697242492 166428961 72628719 361639205 499632513 554631323 305233223 309029649 197725655 853581515 286740033 873681088 443094922 905119354 596875693 415751020 848371940 176043988 31275150 39747201 676490856 965461580 788056873 43171671 4202...
result:
wrong answer 4th words differ - expected: '55518246', found: '596235635'