QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#476317#143. 最大流(随机数据)WrongAnswer_90#100 ✓11ms4144kbC++175.0kb2024-07-13 18:48:502024-07-13 18:48:53

Judging History

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

  • [2024-07-13 18:48:53]
  • 评测
  • 测评结果:100
  • 用时:11ms
  • 内存:4144kb
  • [2024-07-13 18:48:50]
  • 提交

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 cnt=1,n,m,S,T,head[110],to[10010],nex[10010],v[10010],d[110],now[110];
	inline void Add(int x,int y,int z){to[++cnt]=y,nex[cnt]=head[x],head[x]=cnt,v[cnt]=z;}
	inline void add(int x,int y,int z){Add(x,y,z),Add(y,x,0);}
	inline bool bfs()
	{
		queue<int> q;q.e(S),memset(d,0,sizeof(d)),d[S]=1,now[S]=head[S];
		while(!q.empty())
		{
			int nw=q.front();q.pop();
			for(int i=head[nw];i;i=nex[i])
			{
				if(v[i]&&!d[to[i]])
				{
					d[to[i]]=d[nw]+1,now[to[i]]=head[to[i]],q.e(to[i]);
					if(to[i]==T)return 1;
				}
			}
		}
		return 0;
	}
	int dinic(int x,int flow)
	{
		if(x==T)return flow;
		int t,rest=flow;
		for(int i=now[x];i&&rest;i=nex[i])
		{
			now[x]=i;
			if(!v[i]||d[to[i]]!=d[x]+1)continue;
			t=dinic(to[i],min(rest,v[i]));
			v[i]-=t,rest-=t,v[i^1]+=t;
			if(!t)d[to[i]]=0;
		}
		return flow-rest;
	}
	inline void mian()
	{
		read(n,m,S,T);int x,y,z,s=0;
		for(int i=1;i<=m;++i)read(x,y,z),add(x,y,z);
		while(bfs())while((x=dinic(S,INF)))s+=x;
		write(s);
	}
}
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: 12.5
Accepted
time: 1ms
memory: 3924kb

input:

52 275 1 2
11 18 1
18 48 9
10 15 1
11 19 1
10 20 1
3 14 1
8 16 1
31 32 2147483647
10 42 9
5 14 1
3 15 1
5 17 1
6 50 9
1 6 9
28 29 2147483647
18 40 9
43 42 2147483647
1 9 9
9 20 1
1 7 9
24 6 9
39 38 2147483647
4 14 1
38 37 2147483647
5 46 9
3 18 1
15 44 9
4 17 1
32 33 2147483647
28 9 9
32 9 9
26 12 9...

output:

729 

result:

ok single line: '729 '

Test #2:

score: 12.5
Accepted
time: 1ms
memory: 4008kb

input:

67 4489 14 1
25 63 19983
49 18 26963
9 29 23009
25 30 10286
45 6 14693
61 11 8464
12 19 29821
39 36 2365
12 7 20737
56 51 21002
9 63 14701
15 10 24386
21 36 25930
49 21 10680
56 11 25508
26 27 2101
46 4 1770
16 56 19722
23 8 28411
67 32 28897
45 62 22880
30 38 13226
37 56 18650
10 57 700
62 53 19659...

output:

1025243 

result:

ok single line: '1025243 '

Test #3:

score: 12.5
Accepted
time: 0ms
memory: 3992kb

input:

100 1029 1 2
39 96 19
68 19 19
16 33 1
17 25 1
74 22 19
50 23 19
46 29 19
70 24 19
27 92 19
50 25 19
6 36 1
34 80 19
72 19 19
48 13 19
11 86 19
19 86 19
100 99 2147483647
4 39 1
60 9 19
76 7 19
34 100 19
98 97 2147483647
15 25 1
14 94 19
5 40 1
4 38 1
46 34 19
90 89 2147483647
42 39 19
58 27 19
3 39...

output:

4693 

result:

ok single line: '4693 '

Test #4:

score: 12.5
Accepted
time: 1ms
memory: 4116kb

input:

100 500 64 68
97 1 597234350
42 59 1020828575
52 59 1341185789
46 82 534859215
84 98 1408384018
95 85 97421544
50 51 1658946459
71 91 1071433566
16 5 577259372
79 16 941940144
32 66 2144021311
42 94 132280559
100 83 2093384600
34 98 1633024304
31 69 735801701
68 13 632197336
70 25 868338831
60 91 14...

output:

4259958644 

result:

ok single line: '4259958644 '

Test #5:

score: 12.5
Accepted
time: 0ms
memory: 3980kb

input:

100 1500 30 87
12 52 1212854316
66 34 500229329
28 30 1905848380
45 10 1906211267
35 5 1227091997
14 10 797678626
42 39 2119948760
80 55 263028757
72 32 1402091192
2 70 114204531
53 87 1885940117
39 68 1262963681
20 100 363298998
81 19 475298425
86 17 276841422
95 43 940479356
85 55 1720319570
40 65...

output:

17139501202 

result:

ok single line: '17139501202 '

Test #6:

score: 12.5
Accepted
time: 1ms
memory: 4128kb

input:

100 5000 12 73
5 90 596775756
35 20 226786760
28 31 1775982092
79 17 743002845
10 19 150120683
83 96 901953035
91 62 809520329
2 61 1024423315
30 91 1374494188
93 26 751944004
82 82 727762428
1 43 502389284
84 87 1379778919
52 32 1459460146
71 15 983677176
18 3 249963037
80 32 828290820
40 99 159181...

output:

37381805875 

result:

ok single line: '37381805875 '

Test #7:

score: 12.5
Accepted
time: 11ms
memory: 4144kb

input:

100 5000 13 28
74 16 599476
99 76 112185
76 68 887056
13 2 181381
23 72 214611
10 15 955272
57 53 163306
81 44 721618
68 62 71172
70 44 233121
13 52 701794
77 40 298244
54 28 626039
26 63 829000
25 14 91588
97 62 980457
17 15 572847
100 75 273645
4 65 344467
17 47 299474
40 19 270752
50 68 804106
21...

output:

2193636882 

result:

ok single line: '2193636882 '

Test #8:

score: 12.5
Accepted
time: 6ms
memory: 4132kb

input:

100 5000 66 90
35 39 966842
3 56 577708
38 60 515530
3 73 351251
29 27 508007
56 70 185615
73 51 331650
6 32 589603
29 96 822851
9 99 335209
20 45 806531
60 10 460779
93 21 203582
77 27 391590
3 14 315530
86 41 234991
53 69 96865
97 15 203159
14 43 815111
4 24 337097
88 79 288209
64 34 806690
13 26 ...

output:

4340954172 

result:

ok single line: '4340954172 '