QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#659519#9487. Vivid Colorsucup-team3510#RE 4ms6352kbC++141.8kb2024-10-19 20:32:442024-10-19 20:32:46

Judging History

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

  • [2024-10-19 20:32:46]
  • 评测
  • 测评结果:RE
  • 用时:4ms
  • 内存:6352kb
  • [2024-10-19 20:32:44]
  • 提交

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=1;i<=n;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};
		}
	}
	stable_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--)
			{
				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;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3580kb

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: 3624kb

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: 0
Accepted
time: 1ms
memory: 3796kb

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
55518246
226327601
523827415
697242492
166428961
72628719
361639205
499632513
554631323
305233223
309029649
197725655
853581515
286740033
873681088
443094922
905119354
107690174
499165266
848371940
176043988
31275150
39747201
676490856
965461580
788056873
59932649
12538...

result:

ok 144 tokens

Test #4:

score: 0
Accepted
time: 4ms
memory: 6352kb

input:

282
94428 97009 94455
188420 188507 188612
93867 96593 93723
39525 41816 39549
192460 192576 192433
3845 1235 4121
11984 12390 12173
130725 130116 130896
87196 88124 87364
44538 45060 44298
166342 166632 166330
82059 84785 81813
27313 29691 27187
34038 35140 33798
54607 52867 54514
133483 131946 133...

output:

889314432
390117563
692023566
98907387
121626305
562561437
943457514
32985591
579638100
443215860
190588508
100335990
245223619
297117655
983188143
829225394
24317883
294014511
13323940
161909823
702330540
380190451
641303019
179896717
251619007
656550638
566922194
280229585
194457893
858751625
3209...

result:

ok 282 tokens

Test #5:

score: 0
Accepted
time: 4ms
memory: 4276kb

input:

271
153127 153535 152737
23323 22899 22765
34658 35090 35102
105004 105460 105508
137353 137025 137455
123997 123645 123883
11813 12333 11387
144072 144184 144198
190834 190866 191008
134203 134619 133837
160912 160400 161494
120883 121563 120775
183341 182637 183593
111598 112254 111034
34566 35078...

output:

322344
554885983
764388094
286496
120066627
542525190
428080325
887579586
216597238
807704248
412727458
450051205
289652425
201676353
851555207
107659595
407794390
845083057
11262308
601363802
380228455
744523302
119075663
10973283
784763125
915078500
635553912
194849886
439358978
606025095
61708067...

result:

ok 271 tokens

Test #6:

score: -100
Runtime Error

input:

300
104842 113680 113680
143955 136043 136043
29866 29080 29080
109288 101080 101080
172820 180722 180722
125104 118195 118195
24448 26967 26967
77313 70147 70147
24553 20285 20285
53114 43843 43843
42094 36323 36323
128136 118936 118936
71217 79147 79147
121620 123061 123061
100792 97508 97508
6721...

output:


result: