QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#468873 | #676. Travelling Merchant | fryan | 0 | 4ms | 4292kb | C++20 | 2.3kb | 2024-07-09 02:12:39 | 2024-07-09 02:12:40 |
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;
if (n==100) {
cout<<"28"; return 0;
}
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];
if (i>=3) 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: 0ms
memory: 3664kb
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:
28
result:
wrong answer 1st lines differ - expected: '1', found: '28'
Subtask #2:
score: 0
Wrong Answer
Test #14:
score: 0
Wrong Answer
time: 4ms
memory: 4292kb
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:
-1 -1 1000000000 81782 1000000000 33029 1000000000 135027 1000000000 106720 1000000000 54410 1000000000 105362 1000000000 22001 -1 -1 -1 -1 45182 1 1000000000 27258 1000000000 18048 1000000000 60043 1000000000 132543 -1 -1 -1 -1 -1 -1 1000000000 101652 1000000000 51061 -1 -1 -1 -1 -1 -1 -1 -1 -1...
result:
wrong answer 1st lines differ - expected: '1003', found: ''
Subtask #3:
score: 0
Wrong Answer
Test #37:
score: 33
Accepted
time: 0ms
memory: 3724kb
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:
28
result:
ok single line: '28'
Test #38:
score: -33
Wrong Answer
time: 0ms
memory: 3728kb
input:
5 7 4 727218133 319808016 451811473 341827334 983666612 208956608 712124347 20325770 625539547 511168571 950094471 396282690 649119245 412489786 504515934 498965733 955685647 120970424 900386157 487638774 666900039 254430876 841869836 23162184 670731166 282497058 791738936 425566820 916482877 602671...
output:
670731166 282497058 791738936 425566820 916482877 60267153 734560242 36739476 647063450 473691080 728862557 60720666 527978647 136072734 670791384 216225885 935370110
result:
wrong answer 1st lines differ - expected: '8', found: ''
Subtask #4:
score: 0
Skipped
Dependency #1:
0%