QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#525680#676. Travelling MerchantRafi22#12 35ms5344kbC++172.0kb2024-08-20 20:17:122024-08-20 20:17:13

Judging History

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

  • [2024-08-20 20:17:13]
  • 评测
  • 测评结果:12
  • 用时:35ms
  • 内存:5344kb
  • [2024-08-20 20:17:12]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#ifdef DEBUG
auto&operator<<(auto&o,pair<auto,auto>p){return o<<"("<<p.first<<", "<<p.second<<")";}
auto operator<<(auto&o,auto x)->decltype(x.end(),o){o<<"{";int i=0;for(auto e:x)o<<","+!i++<<e;return o<<"}";}
#define debug(X...)cerr<<"["#X"]: ",[](auto...$){((cerr<<$<<"; "),...)<<endl;}(X)
#else
#define debug(...){}
#endif

#define int long long
#define ll long long
#define ld long double
#define endl '\n'
#define st first
#define nd second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define FOR(i,l,r) for(int i=(l);i<=(r);i++)
#define ROF(i,r,l) for(int i=(r);i>=(l);i--)
int inf=1000000007;
ll infl=1000000000000000007;
ll mod=1000000007;
ll mod1=998244353;

const int N=107,K=1007;

int bx[N][K],sx[N][K];
int d[N][N];
int C[N][N];
ll D[N][N];

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,m,k;
    cin>>n>>m>>k;
    FOR(i,1,n) FOR(j,1,k) cin>>bx[i][j]>>sx[i][j];
    FOR(i,1,n) 
    {
		FOR(j,1,n)
		{
			if(i==j) continue;
			d[i][j]=inf;
			FOR(l,1,k) if(sx[j][l]!=-1&&bx[i][l]!=-1) C[i][j]=max(C[i][j],sx[j][l]-bx[i][l]);
		}
	}
    FOR(i,1,m)
    {
		int a,b,c;
		cin>>a>>b>>c;
		d[a][b]=min(d[a][b],c);
	}
	FOR(t,1,n) FOR(i,1,n) FOR(j,1,n) d[i][j]=min(d[i][j],d[i][t]+d[t][j]);
	/*ll ans=0;
	FOR(i,2,n) ans=max(ans,C[1][i]/(d[1][i]+d[i][1]));
	cout<<ans<<endl;*/
	int l=1,r=1000000000,ans=0;
	while(l<=r)
	{
		int sr=(l+r)/2;
		FOR(i,1,n)
		{
			FOR(j,1,n)
			{
				if(i==j) D[i][j]=0;
				else 
				{
					if(d[i][j]==inf) D[i][j]=-infl;
					else D[i][j]=(ll)C[i][j]-(ll)sr*(ll)d[i][j];
				}
			}
		}
		bool ok=0;
		//FOR(i,2,n) if(D[1][i]+D[i][1]>=0) ok=1;
		/*FOR(t,1,n) FOR(i,1,n) FOR(j,1,n) D[i][j]=max(D[i][j],D[i][t]+D[t][j]);*/
		FOR(i,1,n) FOR(j,1,n) if(i!=j) if(D[i][j]+D[j][i]>=0) ok=1;
		if(ok)
		{
			ans=sr;
			l=sr+1;
		}
		else r=sr-1;
	}
	cout<<ans<<endl;
	
    
    
    
    
    return 0;
}


Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 12
Accepted

Test #1:

score: 12
Accepted
time: 20ms
memory: 5304kb

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:

1

result:

ok single line: '1'

Test #2:

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

input:

100 100 1
1 1
-1 1000000000
-1 1000000000
-1 1000000000
-1 1000000000
-1 1000000000
-1 1000000000
-1 1000000000
-1 1000000000
-1 1000000000
-1 1000000000
-1 1000000000
-1 1000000000
-1 1000000000
-1 1000000000
-1 1000000000
-1 1000000000
-1 1000000000
-1 1000000000
-1 1000000000
-1 1000000000
-1 100...

output:

0

result:

ok single line: '0'

Test #3:

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

input:

100 100 1
1 1
-1 1000000000
-1 1000000000
-1 1000000000
-1 1000000000
-1 1000000000
-1 1000000000
-1 1000000000
-1 1000000000
-1 1000000000
-1 1000000000
-1 1000000000
-1 1000000000
-1 1000000000
-1 1000000000
-1 1000000000
-1 1000000000
-1 1000000000
-1 1000000000
-1 1000000000
-1 1000000000
-1 100...

output:

9999999

result:

ok single line: '9999999'

Test #4:

score: 12
Accepted
time: 1ms
memory: 4108kb

input:

50 98 1
294990003 -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 481362725
-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:

1968

result:

ok single line: '1968'

Test #5:

score: 12
Accepted
time: 1ms
memory: 4048kb

input:

50 146 2
159591094 -1 152896514 -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 962186931
-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:

12512

result:

ok single line: '12512'

Test #6:

score: 12
Accepted
time: 1ms
memory: 4104kb

input:

50 50 3
724315557 40661616 888500313 492213321 669530670 343751759
-1 349184557 -1 123681117 -1 416489184
-1 376740434 -1 524659730 -1 308601359
-1 544715761 -1 206108083 -1 241453594
-1 500022763 -1 65259007 -1 210716628
-1 32350566 -1 167450879 -1 397678219
-1 484826182 -1 132481950 -1 139031923
-...

output:

0

result:

ok single line: '0'

Test #7:

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

input:

50 50 50
891479383 484772280 972520765 460897526 852794515 220696128 675355181 162826783 595520625 317178479 928536077 41783603 637233354 48683751 939337578 12210312 835648124 328095767 884417707 439843653 604057461 198149458 682206647 375826043 628570854 479841622 973619107 171111598 901599380 4192...

output:

1200008

result:

ok single line: '1200008'

Test #8:

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

input:

4 4 1
1 -1
-1 2
-1 17
-1 15
1 2 1
2 3 1
3 4 1
4 1 1

output:

4

result:

ok single line: '4'

Test #9:

score: 12
Accepted
time: 1ms
memory: 4112kb

input:

50 50 1
1 1
-1 1000000000
-1 1000000000
-1 1000000000
-1 1000000000
-1 1000000000
-1 1000000000
-1 1000000000
-1 1000000000
-1 1000000000
-1 1000000000
-1 1000000000
-1 1000000000
-1 1000000000
-1 1000000000
-1 1000000000
-1 1000000000
-1 1000000000
-1 1000000000
-1 1000000000
-1 1000000000
-1 10000...

output:

19999999

result:

ok single line: '19999999'

Test #10:

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

input:

50 146 10
751094001 488028533 670635071 279189552 719865752 62857436 945035157 99942140 635724731 336304928 539721394 260175851 762704228 41970290 951557180 106161633 464415091 134662977 833758012 522554183
-1 30927372 -1 281363132 -1 64696223 -1 35169633 -1 426745823 -1 235500852 -1 380932326 -1 16...

output:

20025608

result:

ok single line: '20025608'

Test #11:

score: 12
Accepted
time: 1ms
memory: 4196kb

input:

50 144 5
669304181 -1 479970956 -1 167649828 -1 470258299 -1 885426197 -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 -...

output:

65926480

result:

ok single line: '65926480'

Test #12:

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

input:

10 18 1
167140269 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 -1
-1 902165905
-1 -1
-1 -1
9 3 1
3 8 1
4 6 1
5 1 1
2 1 1
6 1 1
2 7 1
8 7 1
2 5 1
1 2 1
1 6 1
8 4 1
7 1 1
1 9 1
10 1 1
2 10 1
3 7 1
9 5 1

output:

147005127

result:

ok single line: '147005127'

Test #13:

score: 12
Accepted
time: 1ms
memory: 4156kb

input:

50 100 50
853543611 84398909 750508785 293224633 467984755 368609270 660008525 69724893 777295826 543143283 660075741 355270173 942285924 207494807 940093193 281162609 535796018 299388697 712530736 204347888 999684888 220043146 779150015 396635929 891605908 484405769 785572566 4921986 907713030 7234...

output:

0

result:

ok single line: '0'

Subtask #2:

score: 0
Wrong Answer

Test #14:

score: 21
Accepted
time: 1ms
memory: 4164kb

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: 21
Accepted
time: 1ms
memory: 4080kb

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
Wrong Answer
time: 1ms
memory: 4204kb

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:

199

result:

wrong answer 1st lines differ - expected: '203', found: '199'

Subtask #3:

score: 0
Wrong Answer

Test #37:

score: 0
Wrong Answer
time: 35ms
memory: 5344kb

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:

1

result:

wrong answer 1st lines differ - expected: '28', found: '1'

Subtask #4:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%