QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#340899#905. 三元环枚举ffffyc#AC ✓59ms31444kbC++141.5kb2024-02-29 13:57:162024-02-29 13:57:17

Judging History

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

  • [2024-02-29 13:57:17]
  • 评测
  • 测评结果:AC
  • 用时:59ms
  • 内存:31444kb
  • [2024-02-29 13:57:16]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long
namespace IO{//by cyffff
	int len=0;
	char ibuf[(1<<21)+1],*iS,*iT,out[(1<<25)+1];
	#if ONLINE_JUDGE
	#define gh() (iS==iT?iT=(iS=ibuf)+fread(ibuf,1,(1<<21)+1,stdin),(iS==iT?EOF:*iS++):*iS++)
 	#else
	#define gh() getchar()
	#endif
	#define reg register
	inline int read(){
		reg char ch=gh();
		reg int x=0;
		reg char t=0;
		while(ch<'0'||ch>'9')   t|=ch=='-',ch=gh();
		while(ch>='0'&&ch<='9') x=x*10+(ch^48),ch=gh();
		return t?-x:x;
	}
	inline void putc(char ch){
		out[len++]=ch;
	}
	template<class T>
	inline void write(T x){
		if(x<0)putc('-'),x=-x;
		if(x>9)write(x/10);
		out[len++]=x%10+48;
	}
	inline void flush(){
		fwrite(out,1,len,stdout);
		len=0;
	}
	inline char getc(){
		char ch=gh();
		while(ch<'A'||ch>'Z') ch=gh();
		return ch;
	}
}
using IO::read;
using IO::write;
using IO::flush;
using IO::getc;
using IO::putc;
const int N=4e5+10,mod=998244353;
int n,m,d[N],v[N],s;
vector<int>a[N],b[N];
int vis[N];
int main(){
	n=read(),m=read();
	for(int i=1;i<=n;i++)
		v[i]=read();
	for(int i=1;i<=m;i++){
		int u=read()+1,v=read()+1;
		b[u].push_back(v),b[v].push_back(u);
		d[u]++,d[v]++;
	}
	for(int i=1;i<=n;i++)
		for(auto j:b[i])
			if(d[i]<d[j]||i<j&&d[i]==d[j])
				a[i].push_back(j);
	for(int i=1;i<=n;i++){
		for(int j:a[i])
			vis[j]=i;
		for(int j:a[i])
			for(int k:a[j])
				if(vis[k]==i)
					s=(s+1ll*v[i]*v[j]%mod*v[k])%mod;
	}
	write(s);
	flush();
}

这程序好像有点Bug,我给组数据试试?

详细

Test #1:

score: 100
Accepted
time: 4ms
memory: 22396kb

input:

4 5
1 2 3 4
0 3
2 0
2 1
2 3
1 3

output:

36

result:

ok "36"

Test #2:

score: 0
Accepted
time: 12ms
memory: 25472kb

input:

17707 77101
528756313 434883274 318065816 264440383 659789617 608119380 648104885 725454492 696703871 543030428 663661240 890791532 108201616 428505484 322953840 119811886 691103780 306647414 549862302 176916719 909058872 455464665 307270851 584469329 722629343 875317523 629938577 244419357 78121457...

output:

397965084

result:

ok "397965084"

Test #3:

score: 0
Accepted
time: 8ms
memory: 25580kb

input:

69830 19691
136987924 40280999 438515315 805152546 234164454 129099933 971852321 983937488 410134225 668461222 574343409 885417013 394300887 86086437 570981511 221329455 57893312 584381871 154204049 738660729 728257729 551666498 540440394 165573287 512342480 452470821 669622703 340240729 965382636 9...

output:

0

result:

ok "0"

Test #4:

score: 0
Accepted
time: 12ms
memory: 27088kb

input:

53336 61958
288974909 111681588 291303632 155763712 177741457 164199418 280452914 745629015 727272894 383855815 451963117 263419161 854025925 625817844 903511050 636159790 788165373 442332844 275132246 358996390 239303569 23523747 398318281 935986353 142493592 695297770 499848367 7061287 551242323 6...

output:

906430555

result:

ok "906430555"

Test #5:

score: 0
Accepted
time: 59ms
memory: 24652kb

input:

447 99681
192279220 156648746 154396384 640494892 528756313 434883274 318065816 264440383 659789617 608119380 648104885 725454492 696703871 543030428 663661240 890791532 108201616 428505484 322953840 119811886 691103780 306647414 549862302 176916719 909058872 455464665 307270851 584469329 722629343 ...

output:

687388905

result:

ok "687388905"

Test #6:

score: 0
Accepted
time: 26ms
memory: 30744kb

input:

100000 100000
192279220 156648746 154396384 640494892 528756313 434883274 318065816 264440383 659789617 608119380 648104885 725454492 696703871 543030428 663661240 890791532 108201616 428505484 322953840 119811886 691103780 306647414 549862302 176916719 909058872 455464665 307270851 584469329 722629...

output:

544299331

result:

ok "544299331"

Test #7:

score: 0
Accepted
time: 21ms
memory: 30660kb

input:

100000 100000
264704197 120999146 136987924 40280999 438515315 805152546 234164454 129099933 971852321 983937488 410134225 668461222 574343409 885417013 394300887 86086437 570981511 221329455 57893312 584381871 154204049 738660729 728257729 551666498 540440394 165573287 512342480 452470821 669622703...

output:

173075458

result:

ok "173075458"

Test #8:

score: 0
Accepted
time: 25ms
memory: 30628kb

input:

100000 100000
682152023 451794314 2028037 288974909 111681588 291303632 155763712 177741457 164199418 280452914 745629015 727272894 383855815 451963117 263419161 854025925 625817844 903511050 636159790 788165373 442332844 275132246 358996390 239303569 23523747 398318281 935986353 142493592 695297770...

output:

914677810

result:

ok "914677810"

Test #9:

score: 0
Accepted
time: 9ms
memory: 22432kb

input:

2 1
1 2
0 1

output:

0

result:

ok "0"

Test #10:

score: 0
Accepted
time: 0ms
memory: 22364kb

input:

181 1323
154396384 640494892 528756313 434883274 318065816 264440383 659789617 608119380 648104885 725454492 696703871 543030428 663661240 890791532 108201616 428505484 322953840 119811886 691103780 306647414 549862302 176916719 909058872 455464665 307270851 584469329 722629343 875317523 629938577 2...

output:

810000936

result:

ok "810000936"

Test #11:

score: 0
Accepted
time: 9ms
memory: 22820kb

input:

198 17685
40280999 438515315 805152546 234164454 129099933 971852321 983937488 410134225 668461222 574343409 885417013 394300887 86086437 570981511 221329455 57893312 584381871 154204049 738660729 728257729 551666498 540440394 165573287 512342480 452470821 669622703 340240729 965382636 953292241 144...

output:

893263934

result:

ok "893263934"

Test #12:

score: 0
Accepted
time: 3ms
memory: 22444kb

input:

88 1419
2028037 288974909 111681588 291303632 155763712 177741457 164199418 280452914 745629015 727272894 383855815 451963117 263419161 854025925 625817844 903511050 636159790 788165373 442332844 275132246 358996390 239303569 23523747 398318281 935986353 142493592 695297770 499848367 7061287 5512423...

output:

285141028

result:

ok "285141028"

Test #13:

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

input:

181 299
154396384 640494892 528756313 434883274 318065816 264440383 659789617 608119380 648104885 725454492 696703871 543030428 663661240 890791532 108201616 428505484 322953840 119811886 691103780 306647414 549862302 176916719 909058872 455464665 307270851 584469329 722629343 875317523 629938577 24...

output:

68968143

result:

ok "68968143"

Test #14:

score: 0
Accepted
time: 3ms
memory: 22412kb

input:

198 235
136987924 40280999 438515315 805152546 234164454 129099933 971852321 983937488 410134225 668461222 574343409 885417013 394300887 86086437 570981511 221329455 57893312 584381871 154204049 738660729 728257729 551666498 540440394 165573287 512342480 452470821 669622703 340240729 965382636 95329...

output:

273857930

result:

ok "273857930"

Test #15:

score: 0
Accepted
time: 0ms
memory: 22328kb

input:

88 139
2028037 288974909 111681588 291303632 155763712 177741457 164199418 280452914 745629015 727272894 383855815 451963117 263419161 854025925 625817844 903511050 636159790 788165373 442332844 275132246 358996390 239303569 23523747 398318281 935986353 142493592 695297770 499848367 7061287 55124232...

output:

351774600

result:

ok "351774600"

Test #16:

score: 0
Accepted
time: 16ms
memory: 31424kb

input:

100000 99999
192279220 156648746 154396384 640494892 528756313 434883274 318065816 264440383 659789617 608119380 648104885 725454492 696703871 543030428 663661240 890791532 108201616 428505484 322953840 119811886 691103780 306647414 549862302 176916719 909058872 455464665 307270851 584469329 7226293...

output:

0

result:

ok "0"

Test #17:

score: 0
Accepted
time: 20ms
memory: 31444kb

input:

100000 99999
264704197 120999146 136987924 40280999 438515315 805152546 234164454 129099933 971852321 983937488 410134225 668461222 574343409 885417013 394300887 86086437 570981511 221329455 57893312 584381871 154204049 738660729 728257729 551666498 540440394 165573287 512342480 452470821 669622703 ...

output:

0

result:

ok "0"