QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#476246#415. 最小生成树WrongAnswer_90#20 92ms11388kbC++174.4kb2024-07-13 18:23:122024-07-13 18:23:12

Judging History

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

  • [2024-07-13 18:23:12]
  • 评测
  • 测评结果:20
  • 用时:92ms
  • 内存:11388kb
  • [2024-07-13 18:23:12]
  • 提交

answer

#include<bits/stdc++.h>
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define ll long long
#define lll __int128
#define fi first
#define se second
#define e emplace
#define eb emplace_back
#define db double
#define ef emplace_front
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vp vector<pii>
#define mp make_pair

//#define LOCALJUDGE
//#define int ll
bool ST;
static const ll MOD=998244353,Phi=998244352,inv2=499122177,Root=3,iRoot=332748118;
static const ll inf=1073741823,INF=4557430888798830399;
static const double eps=1e-8,pi=3.1415926535;
char in[1<<20],*p1=in,*p2=in;
using namespace std;
// #define getchar() (p1==p2&&(p2=(p1=in)+fread(in,1,1<<20,stdin),p1==p2)?EOF:*p1++)
struct tup{int x,y,z;tup(int X=0,int Y=0,int Z=0){x=X,y=Y,z=Z;}};
namespace FastIO
{
	template<typename T> inline void write(T x,char ch=' ')
	{
		if(is_same<char,T>::value)putchar(x);
		else
		{
			if(x<0)x=-x,putchar('-');

			static char st[50];int top=0;
			do{st[top++]=x%10+'0',x/=10;}while(x);
			while(top)putchar(st[--top]);
		}
		ch!='~'?putchar(ch):0;
	}
	inline void write(const char*x,char ch=' ')
	{
		for(int i=0;x[i]!='\0';++i)putchar(x[i]);
		ch!='~'?putchar(ch):0;
	}
	inline void read(char&s){do s=getchar();while(s=='\n'||s==' ');}
	inline void read(char s[])
	{
		int len=0;char st;
		do st=getchar();while(st=='\n'||st==' ');
		s[++len]=st,st=getchar();
		while(st!='\n'&&st!=' ')s[++len]=st,st=getchar();
		s[++len]='\0';
	}
	template<typename T> inline void read(T &s)
	{
		s=0;char ch=getchar();
		while((ch>'9'||ch<'0')&&ch!='-')ch=getchar();
		bool tf=(ch=='-')&&(ch=getchar());
		while((ch>='0')&&(ch<='9'))s=(s<<1)+(s<<3)+ch-'0',ch=getchar();
		s=(tf?-s:s);
	}
	template<typename T1,typename T2> inline void read(pair<T1,T2> &s){read(s.fi),read(s.se);}
	template<typename T,typename...Args> inline void write(T x,Args...args){write(x,'~'),write(args...);}
	template<typename T,typename...Args> inline void read(T&x,Args&...args){read(x),read(args...);}
}
using namespace FastIO;
namespace MTool
{
	inline int Cadd(int a,int b){return (ll)a+b>=MOD?(ll)a+b-MOD:a+b;}
	inline int Cdel(int a,int b){return a-b<0?a-b+MOD:a-b;}
	inline int Cmul(int a,int b){return 1ll*a*b%MOD;}
	inline int sqr(int a){return 1ll*a*a%MOD;}
	inline void Madd(int&a,int b){a=((ll)a+b>=MOD?(ll)a+b-MOD:a+b);}
	inline void Mdel(int&a,int b){a=(a-b<0?a-b+MOD:a-b);}
	inline void Mmul(int&a,int b){a=1ll*a*b%MOD;}
	template<typename T> inline bool Mmax(T&a,T b){return a<b?a=b,1:0;}
	template<typename T> inline bool Mmin(T&a,T b){return a>b?a=b,1:0;}
	template<typename...Args> inline void Madd(int&a,int b,Args...args){Madd(a,b),Madd(a,args...);}
	template<typename...Args> inline void Mmul(int&a,int b,Args...args){Mmul(a,b),Mmul(a,args...);}
	template<typename...Args> inline void Mdel(int&a,int b,Args...args){Mdel(a,b),Mdel(a,args...);}
	template<typename...Args> inline int Cadd(int a,int b,Args...args){return Cadd(Cadd(a,b),args...);}
	template<typename...Args> inline int Cmul(int a,int b,Args...args){return Cmul(Cmul(a,b),args...);}
	template<typename...Args> inline int Cdel(int a,int b,Args...args){return Cdel(Cdel(a,b),args...);}
	template<typename...Args,typename T> inline bool Mmax(T&a,T b,Args...args){return Mmax(a,b)|Mmax(a,args...);}
	template<typename...Args,typename T> inline bool Mmin(T&a,T b,Args...args){return Mmin(a,b)|Mmin(a,args...);}
	inline int power(int x,int y){int s=1;for(;y;y>>=1,Mmul(x,x))if(y&1)Mmul(s,x);return s;}
}
using namespace MTool;
namespace WrongAnswer_90
{
	int n,m,ans,fa[200010];
	tup b[500010];
	int find(int x){return x==fa[x]?x:fa[x]=find(fa[x]);}
	inline bool cmp(tup x,tup y){return x.z<y.z;}
	inline void mian()
	{
		read(n,m);
		for(int i=1;i<=n;++i)fa[i]=i;
		for(int i=1;i<=m;++i)read(b[i].x,b[i].y,b[i].z);
		sort(b+1,b+1+m,cmp);
		for(int i=1;i<=m;++i)
		{
			int x=find(b[i].x),y=find(b[i].y);
			if(x==y)continue;
			ans+=b[i].z,fa[x]=y;
		}
		write(ans);
	}
}
bool ED;
signed main()
{
	#ifdef LOCALJUDGE
	freopen("ex_mod5.in","r",stdin);
	freopen("1.out","w",stdout);
	#endif
	double st=clock();
	WrongAnswer_90::mian();
	double ed=clock();
	#ifndef LOCALJUDGE
 	cerr<<endl;
	#endif
 	cerr<<"Time: "<<ed-st<<" ms\n";
	#ifdef LOCALJUDGE
 	cerr<<"     ";
	#endif
 	cerr<<"Memory: "<<abs(&ST-&ED)/1024.0/1024.0<<" MB\n";
	return 0;
}

详细

Test #1:

score: 10
Accepted
time: 0ms
memory: 11376kb

input:

1 0

output:

0 

result:

ok answer is '0'

Test #2:

score: 10
Accepted
time: 62ms
memory: 10760kb

input:

1 500000
1 1 436085873
1 1 289134331
1 1 95168426
1 1 809912668
1 1 912905316
1 1 51427205
1 1 808052925
1 1 168547991
1 1 469573116
1 1 7523372
1 1 700424384
1 1 329491017
1 1 886380039
1 1 92596215
1 1 870407506
1 1 420928567
1 1 29439913
1 1 851970613
1 1 595343843
1 1 150074451
1 1 981248098
1 1...

output:

0 

result:

ok answer is '0'

Test #3:

score: 0
Wrong Answer
time: 0ms
memory: 11388kb

input:

1049 1095
37 1027 185663189
439 923 842401821
92 68 172561838
108 320 929023969
537 284 451497914
161 836 18296000
101 14 582350247
82 947 633276668
555 731 321285985
282 946 133823187
549 982 59411620
19 151 982845654
961 22 185979994
201 958 42654715
178 446 121754463
100 386 87537747
492 486 2228...

output:

-248576092 

result:

wrong answer expected '459312924580', found '-248576092'

Test #4:

score: 0
Wrong Answer
time: 76ms
memory: 10496kb

input:

1677 500000
1010 1055 334171722
32 548 496908773
1662 273 215127528
1596 969 799111789
993 895 816193284
335 56 975688725
1537 1674 694838017
512 1006 84989138
487 1094 77423013
1131 522 260247889
32 1581 652804125
1472 1609 861174323
1083 230 236457705
1009 593 692730522
709 284 647880265
936 1598 ...

output:

-868096889 

result:

wrong answer expected '3426870407', found '-868096889'

Test #5:

score: 0
Wrong Answer
time: 71ms
memory: 9856kb

input:

4782 500000
401 2704 143282494
408 742 221495274
2487 2740 328112333
1471 3347 678117943
2369 3844 94084087
4137 629 771103
1506 2976 377332399
3856 3529 15354521
977 1747 267860558
2561 1837 234002816
1947 1191 447985398
2575 3486 210906740
321 1319 879712756
3660 3019 926744290
4492 528 110850246
...

output:

-1082924132 

result:

wrong answer expected '20391912348', found '-1082924132'

Test #6:

score: 0
Wrong Answer
time: 42ms
memory: 10140kb

input:

100000 250000
11249 63248 716981925
77587 45081 715237577
40869 43888 384028427
68447 21259 718879057
15416 4835 542698454
86984 39250 200243926
38485 9822 321829618
68650 80338 208779180
93995 71720 970100731
62306 65602 758670337
12962 93202 405549936
11239 70788 481995017
65169 11656 137255256
93...

output:

-821786920 

result:

wrong answer expected '19768912676568', found '-821786920'

Test #7:

score: 0
Wrong Answer
time: 44ms
memory: 10152kb

input:

100000 250000
58087 98694 276928916
81020 20563 474360924
54330 72482 965233532
69316 62625 693679792
68391 25019 626212979
66635 9065 208396713
18722 31967 29636156
18804 17430 126344131
52091 61058 813889563
22524 92717 616323226
91592 59352 7003125
39568 15009 745751969
59457 33731 34864625
3185 ...

output:

816593620 

result:

wrong answer expected '19671766809300', found '816593620'

Test #8:

score: 0
Wrong Answer
time: 30ms
memory: 11304kb

input:

200000 199999
65210 94695 20344717
27677 60426 947830254
44160 166001 68537440
144553 10242 174779136
72796 113802 266364597
1858 24797 628448494
194099 76945 666582594
133683 17237 128244232
152149 91422 110103130
150169 10041 739399998
136455 75250 7894691
81174 102926 26871471
27780 63438 7883747...

output:

-193303015 

result:

wrong answer expected '94124014988825', found '-193303015'

Test #9:

score: 0
Wrong Answer
time: 92ms
memory: 10888kb

input:

200000 500000
46671 50310 339946279
111950 44341 976219244
183028 30375 283623377
119684 483 278812425
123223 173434 86847632
53396 67926 343986583
195715 85791 872435965
51759 67385 324694963
132645 146330 74109089
142363 58800 508205119
151247 105471 160455427
97528 133772 68416120
33125 33151 102...

output:

-81347915 

result:

wrong answer expected '39818560453301', found '-81347915'

Test #10:

score: 0
Wrong Answer
time: 92ms
memory: 10568kb

input:

200000 500000
45588 17449 500297001
167443 90625 840063438
184162 31916 123322602
75130 105595 80124915
4990 23835 842648585
198193 138933 377398791
61179 68315 899014505
170138 8312 214877618
130847 183955 648135341
186493 178082 135732043
34104 128022 298311436
180739 90096 241294500
90919 4640 35...

output:

-1921606936 

result:

wrong answer expected '39679281240808', found '-1921606936'