QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#104772#676. Travelling Merchantfzj200721 11ms3720kbC++172.2kb2023-05-11 22:17:192023-05-11 22:17:21

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-11 22:17:21]
  • 评测
  • 测评结果:21
  • 用时:11ms
  • 内存:3720kb
  • [2023-05-11 22:17:19]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
namespace IO{
	template<typename T>inline bool read(T &x){
		x=0;
		char ch=getchar();
		bool flag=0,ret=0;
		while(ch<'0'||ch>'9') flag=flag||(ch=='-'),ch=getchar();
		while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar(),ret=1;
		x=flag?-x:x;
        return ret;
	}
	template<typename T,typename ...Args>inline bool read(T& a,Args& ...args){
	    return read(a)&&read(args...);
	}
	template<typename T>void prt(T x){
		if(x>9) prt(x/10);
		putchar(x%10+'0');
	}
	template<typename T>inline void put(T x){
		if(x<0) putchar('-'),x=-x;
		prt(x);
	}
	template<typename T>inline void put(char ch,T x){
		if(x<0) putchar('-'),x=-x;
		prt(x);
		putchar(ch);
	}
	template<typename T,typename ...Args>inline void put(T a,Args ...args){
	    put(a);
		put(args...);
	}
	template<typename T,typename ...Args>inline void put(const char ch,T a,Args ...args){
	    put(ch,a);
		put(ch,args...);
	}
	inline void put(string s){
		for(int i=0,sz=s.length();i<sz;i++) putchar(s[i]);
	}
	inline void put(const char* s){
		for(int i=0,sz=strlen(s);i<sz;i++) putchar(s[i]);
	}
}
using namespace IO;
#define N 105
#define int long long
int n,m,t,A[N][N],B[N][N],g[N][N],f[N][N];
inline bool check(int val){
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++) f[i][j]=0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			for(int k=1;k<=t;k++)
				if(i!=j&&A[i][k]!=-1&&B[j][k]!=-1) f[i][j]=max(f[i][j],B[j][k]-A[i][k]); 
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++) f[i][j]-=g[i][j]*val;
	for(int k=1;k<=n;k++)
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++)
				f[i][j]=max(f[i][j],f[i][k]+f[k][j]);
	for(int i=1;i<=n;i++)
		if(f[i][i]>=0) return 1;
	return 0;
}
signed main(){
	read(n,m,t);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=t;j++) read(A[i][j],B[i][j]);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++) g[i][j]=1e9;
	for(int i=1,u,v,w;i<=m;i++)
		read(u,v,w),g[u][v]=min(g[u][v],w);
	for(int k=1;k<=n;k++)
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++) g[i][j]=min(g[i][j],g[i][k]+g[k][j]);	
	int l=0,r=1e9,res=0;
	while(l<=r){
		int mid=l+r>>1;
		if(check(mid)) l=mid+1,res=mid;
		else r=mid-1;
	}			
	put('\n',res);
	return 0;
}


Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Runtime Error

Test #1:

score: 0
Runtime Error

input:

100 181 1000
553730496 158361961 892706912 178296397 743382683 297380306 641674485 99624440 917350062 18856036 844421978 187895310 648680590 312745394 560991872 402321479 712754581 166489560 776432653 57402415 554268728 511597509 861517186 541462029 843246768 457630601 923371196 521104850 557772066 ...

output:


result:


Subtask #2:

score: 21
Accepted

Test #14:

score: 21
Accepted
time: 3ms
memory: 3612kb

input:

50 50 20
1000000000 94476 1000000000 75837 1000000000 27079 1000000000 129004 1000000000 100830 1000000000 98560 1000000000 99302 1000000000 65993 30410 1 1000000000 66183 1000000000 89148 1000000000 21236 1000000000 11935 1000000000 53895 1000000000 126490 1000000000 104741 1000000000 78615 1000000...

output:

1003

result:

ok single line: '1003'

Test #15:

score: 0
Accepted
time: 1ms
memory: 3536kb

input:

50 50 10
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 339508586 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1...

output:

15782746

result:

ok single line: '15782746'

Test #16:

score: 0
Accepted
time: 7ms
memory: 3532kb

input:

50 50 50
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 12 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 10000 10000 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...

output:

203

result:

ok single line: '203'

Test #17:

score: 0
Accepted
time: 7ms
memory: 3544kb

input:

48 48 50
-1 -1 10002 10002 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 10 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 ...

output:

212

result:

ok single line: '212'

Test #18:

score: 0
Accepted
time: 7ms
memory: 3448kb

input:

50 50 50
662985743 94901609 899384837 65628166 673532122 180059305 627752310 127592351 824072744 87540640 507122543 377977048 635262419 187630987 838541684 187757801 577199874 274873255 694303855 184204318 853356130 175381182 520003147 69588361 734732717 178931356 807461406 173458145 548944353 44467...

output:

24700682

result:

ok single line: '24700682'

Test #19:

score: 0
Accepted
time: 2ms
memory: 3420kb

input:

5 6 2
-1 7 -1 120
-1 -1 -1 152
1 -1 -1 -1
-1 15 -1 101
-1 -1 100 -1
1 2 1
2 3 1
3 1 1
1 4 1
4 5 1
5 1 1

output:

11

result:

ok single line: '11'

Test #20:

score: 0
Accepted
time: 5ms
memory: 3536kb

input:

50 80 10
1000000000 37352 1000000000 17646 1000000000 70743 1000000000 72743 1000000000 92712 1000000000 101408 1000000000 87555 1000000000 93907 1000000000 29236 1000000000 76657
-1 -1 -1 -1 -1 -1 -1 -1 93712 1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -...

output:

888

result:

ok single line: '888'

Test #21:

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

input:

50 100 50
1000000000 70830 1000000000 63070 1000000000 61439 1000000000 61975 1000000000 22624 1000000000 49915 1000000000 47462 1000000000 87935 1000000000 56993 1000000000 46192 1000000000 61181 1000000000 24487 1000000000 8489 1000000000 100547 1000000000 11972 1000000000 62570 1000000000 31811 1...

output:

1280

result:

ok single line: '1280'

Test #22:

score: 0
Accepted
time: 6ms
memory: 3568kb

input:

50 80 20
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 145057260 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 280991963 280991963 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 71816531 71816531 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 ...

output:

48692368

result:

ok single line: '48692368'

Test #23:

score: 0
Accepted
time: 7ms
memory: 3672kb

input:

50 80 40
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 973674914 973674914 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 296561603 -1 -1 -1 282336401 -1...

output:

33194691

result:

ok single line: '33194691'

Test #24:

score: 0
Accepted
time: 6ms
memory: 3616kb

input:

50 187 50
830841810 429573274 595571573 146280515 492250538 468812018 776848926 319177361 666252349 496736685 750060714 515499313 566368754 72927424 974159134 479439560 975472850 125615878 906298599 169893639 719670509 271733463 473128793 364199681 542408747 370312066 503590319 281153746 632823527 2...

output:

61255181

result:

ok single line: '61255181'

Test #25:

score: 0
Accepted
time: 11ms
memory: 3572kb

input:

50 100 50
969635460 427508760 863039420 144198933 533634353 456547090 948068930 449609376 504513760 100099688 594014427 331720624 719966879 183098785 681359049 221725712 908596608 69523431 658733082 411951994 531063785 530194941 517539642 514023120 878107325 175669958 531003748 120509045 769867951 4...

output:

48262703

result:

ok single line: '48262703'

Test #26:

score: 0
Accepted
time: 5ms
memory: 3616kb

input:

50 2450 1
873538879 77537323
981428881 443257378
706113412 86188501
551816872 136407163
775854228 529874644
833357312 164234816
789796900 161224551
782938565 351773996
524273413 221302707
670302513 194826791
930267291 92690365
465264422 198885657
837453031 461954416
892265285 142180433
613974685 497...

output:

35859005

result:

ok single line: '35859005'

Test #27:

score: 0
Accepted
time: 5ms
memory: 3572kb

input:

50 200 21
643668133 390520483 658543702 388943069 605637169 338250245 944977442 19085220 744455499 469334973 716186529 376723863 822608487 261409511 835985600 194242073 849987225 307993073 671141152 436231948 688823523 216262977 460579236 402881121 785133016 549171256 601998630 17008520 626607192 27...

output:

49223640

result:

ok single line: '49223640'

Test #28:

score: 0
Accepted
time: 11ms
memory: 3680kb

input:

50 2450 50
502077015 469045625 489968527 452674638 505803345 496827751 538648562 465058738 545376062 536770029 515365394 476671277 485590735 474944209 516276629 453636182 477817475 460003764 480168383 475732557 458054538 455560310 537744626 499113397 534144232 466826235 549153755 483115613 526201164...

output:

78757153

result:

ok single line: '78757153'

Test #29:

score: 0
Accepted
time: 5ms
memory: 3572kb

input:

50 96 10
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 888211806 888211806
-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -...

output:

46463592

result:

ok single line: '46463592'

Test #30:

score: 0
Accepted
time: 7ms
memory: 3504kb

input:

50 50 50
55859 55859 123482 123482 79889 79889 41061 41061 49131 49131 43257 43257 56425 56425 65649 65649 74722 74722 51980 51980 59441 59441 16955 16955 45044 45044 113078 113078 75246 75246 55050 55050 102102 102102 73125 73125 86088 86088 23312 23312 98013 98013 67756 67756 72788 72788 127435 12...

output:

1167

result:

ok single line: '1167'

Test #31:

score: 0
Accepted
time: 1ms
memory: 3532kb

input:

4 4 3
1 1 5 5 6 6
2 2 8 8 7 7
6 6 9 9 8 8
2 2 7 7 1 1
1 2 1
2 3 1
3 4 1
4 1 1

output:

3

result:

ok single line: '3'

Test #32:

score: 0
Accepted
time: 11ms
memory: 3672kb

input:

50 50 50
1 1 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1...

output:

999999999

result:

ok single line: '999999999'

Test #33:

score: 0
Accepted
time: 11ms
memory: 3616kb

input:

50 191 50
681638163 681638163 343296899 343296899 455415345 455415345 612427809 612427809 520683747 520683747 476224943 476224943 396014800 396014800 570649011 570649011 606265889 606265889 446213315 446213315 446918088 446918088 413684488 413684488 431956363 431956363 331088687 331088687 424310265 ...

output:

406615161

result:

ok single line: '406615161'

Test #34:

score: 0
Accepted
time: 11ms
memory: 3448kb

input:

50 100 50
545869997 545869997 377928992 377928992 450769023 450769023 454866452 454866452 613093501 613093501 477393640 477393640 489106706 489106706 399547137 399547137 601629557 601629557 520007927 520007927 358561182 358561182 593593592 593593592 433980627 433980627 358439100 358439100 521143188 ...

output:

399192910

result:

ok single line: '399192910'

Test #35:

score: 0
Accepted
time: 5ms
memory: 3720kb

input:

50 2450 2
662981629 662981629 429186593 429186593
398152552 398152552 338846288 338846288
345165906 345165906 400176481 400176481
349476026 349476026 579837991 579837991
449954858 449954858 455002792 455002792
408717841 408717841 555085433 555085433
508941564 508941564 593569047 593569047
479450019 ...

output:

323385804

result:

ok single line: '323385804'

Test #36:

score: 0
Accepted
time: 5ms
memory: 3572kb

input:

50 80 3
551325411 551325411 464192800 464192800 480332644 480332644
347097460 347097460 734638978 734638978 584879997 584879997
284204584 284204584 569594556 569594556 684653270 684653270
671544567 671544567 493774054 493774054 536089517 536089517
255657036 255657036 574572675 574572675 494316360 49...

output:

223340615

result:

ok single line: '223340615'

Subtask #3:

score: 0
Runtime Error

Test #37:

score: 0
Runtime Error

input:

100 243 1000
969713863 380451398 977287381 546839551 578242281 267067963 834635238 316438277 806980243 189648353 779415475 453867771 741678190 352485450 473763928 190177433 687118672 377243148 644333594 197290749 949048287 436673078 690006797 180711316 714366028 387342721 980055654 198167471 8873988...

output:


result:


Subtask #4:

score: 0
Skipped

Dependency #1:

0%