QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#468856 | #676. Travelling Merchant | fryan | 0 | 86ms | 5584kb | C++20 | 2.0kb | 2024-07-09 02:01:42 | 2024-07-09 02:01:43 |
Judging History
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;
}
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];
}
}
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;
}
int cp=0;
while (check(cp)) {
cp++;
}
cout<<cp-1;
return 0;
}
詳細信息
Subtask #1:
score: 0
Time Limit Exceeded
Test #1:
score: 12
Accepted
time: 15ms
memory: 5440kb
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: 0
Accepted
time: 3ms
memory: 4692kb
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
Time Limit Exceeded
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:
result:
Subtask #2:
score: 0
Time Limit Exceeded
Test #14:
score: 21
Accepted
time: 86ms
memory: 4304kb
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
Time Limit Exceeded
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:
result:
Subtask #3:
score: 0
Time Limit Exceeded
Test #37:
score: 33
Accepted
time: 56ms
memory: 5584kb
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: 0
Accepted
time: 0ms
memory: 3836kb
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:
8
result:
ok single line: '8'
Test #39:
score: -33
Time Limit Exceeded
input:
50 100 100 738055508 380547266 466519731 321379362 627164749 501738148 790388363 534474035 594031599 289323442 585921101 400847039 988432406 326676078 973287243 480408179 677194803 254403874 960518968 523054718 490930760 258858830 532158736 498097146 823424101 17095805 770242306 523332445 830717940 ...
output:
result:
Subtask #4:
score: 0
Skipped
Dependency #1:
0%