QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#468867#676. Travelling Merchantfryan0 64ms5492kbC++202.3kb2024-07-09 02:11:222024-07-09 02:11:23

Judging History

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

  • [2024-07-09 02:11:23]
  • 评测
  • 测评结果:0
  • 用时:64ms
  • 内存:5492kb
  • [2024-07-09 02:11:22]
  • 提交

answer

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
#define int long long
#define all(x) begin(x), end(x)
#define sz(x) (int) (x).size()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int inf = 0x3f3f3f3f3f3f3f3f;
const int mxn=1e2,mxk=1e3;

int n,m,p;
int bp[mxn][mxk],sp[mxn][mxk];
int adj[mxn][mxn];
int g[mxn][mxn];
int g1[mxn][mxn];

int check(int ef) {
	for (int i=0; i<n; i++) {
		for (int j=0; j<n; j++) {
			g1[i][j] = g[i][j]-ef*adj[i][j];
//			cout<<i<<" "<<j<<": "<<g1[i][j]<<" .. "<<adj[i][j]<<"\n";
		}
	}
	for (int i=0; i<n; i++) {
		for (int j=0; j<n; j++) {
			for (int k=0; k<n; k++) {
				g1[j][k] = max(g1[j][k],g1[j][i]+g1[i][k]);
			}
		}
	}
	for (int i=0; i<n; i++) {
		if (g1[i][i]>=0) return 1;
	}
	return 0;
}

int binary_search(int lo, int hi) {
	if (lo==hi) return lo;
	if (lo+1==hi) {
		if (check(hi)) return hi;
		return lo;
	}
	int mid=(lo+hi)/2;
	if (check(mid)) {
		return binary_search(mid,hi);
	}
	return binary_search(lo,mid-1);
}

signed main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	
	cin>>n>>m>>p;
	memset(adj,0x3f,sizeof(adj));
	for (int i=0; i<n; i++) {
		for (int j=0; j<p; j++) {
			cin>>bp[i][j]>>sp[i][j];
			cout<<bp[i][j]<<" "<<sp[i][j]<<" ";
		}
		cout<<"\n";
	}
	for (int i=0; i<m; i++) {
		int u,v,w; cin>>u>>v>>w; --u; --v;
		adj[u][v] = min(adj[u][v],w);
	}
	for (int i=0; i<n; i++) {
		adj[i][i] = 0;
	}
	for (int i=0; i<n; i++) {
		for (int j=0; j<n; j++) {
			for (int k=0; k<n; k++) {
				if (adj[j][i]==inf || adj[i][k]==inf) continue;
				adj[j][k] = min(adj[j][k],adj[j][i]+adj[i][k]);
			}
		}
	}
	for (int i=0; i<n; i++) {
		for (int j=0; j<n; j++) {
			for (int k=0; k<p; k++) {
				if (bp[i][k]==-1 || sp[j][k]==-1) continue;
				g[i][j] = max(g[i][j],sp[j][k]-bp[i][k]);
			}
		}
		g[i][i]=-inf;
	}	
	cout<<binary_search(0,1e9);
	return 0;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 40ms
memory: 5492kb

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:

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 201053770 640...

result:

wrong answer 1st lines differ - expected: '1', found: '553730496 158361961 892706912 ... 218481522 580197923 220951553 '

Subtask #2:

score: 0
Wrong Answer

Test #14:

score: 0
Wrong Answer
time: 4ms
memory: 4232kb

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:

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 1000000000 93070...

result:

wrong answer 1st lines differ - expected: '1003', found: '1000000000 94476 1000000000 75...0000000 95808 1000000000 45109 '

Subtask #3:

score: 0
Wrong Answer

Test #37:

score: 0
Wrong Answer
time: 64ms
memory: 5492kb

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:

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 887398810 295638288 ...

result:

wrong answer 1st lines differ - expected: '28', found: '969713863 380451398 977287381 ... 135754817 482843919 386306485 '

Subtask #4:

score: 0
Skipped

Dependency #1:

0%