QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#182588#676. Travelling Merchanthngwlog54 90ms5524kbC++142.5kb2023-09-18 10:02:292023-09-18 10:02:29

Judging History

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

  • [2023-09-18 10:02:29]
  • 评测
  • 测评结果:54
  • 用时:90ms
  • 内存:5524kb
  • [2023-09-18 10:02:29]
  • 提交

answer

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

#define int long long
#define fi first
#define se second
#define _size(x) (int)x.size()
#define BIT(i, x) ((x >> i) & 1)
#define MASK(n) ((1 << n) - 1)
#define REP(i, n) for (int i = 0, _n = (n); i < _n; i++)
#define FOR(i, a, b) for (int i = a, _b = (b); i <= _b; i++)
#define FORD(i, a, b) for (int i = a, _b = (b); i >= _b; i--)
#define FORB1(i, mask) for (int i = mask; i > 0; i ^= i & - i)
#define FORB0(i, n, mask) for (int i = ((1 << n) - 1) ^ mask; i > 0; i ^= i & - i)
#define FORALL(i, a) for (auto i: a)
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);

const int inf = 1e9 + 7;
const double EPS = 1e-2;

int n, m, k;
vector<vector<int>> b, s, minD, maxC;
vector<vector<pair<int, int>>> adj;

void load_minDist() {

    FOR(i, 1, n) minD[i][i] = 0;
    FOR(u, 1, n) FORALL(e, adj[u]) minD[u][e.fi] = min(minD[u][e.fi], e.se);
    FOR(k, 1, n) FOR(i, 1, n) FOR(j, 1, n) minD[i][j] = min(minD[i][j], minD[i][k] + minD[k][j]);
}

void load_maxCost() {

    FOR(i, 1, n) {
        FOR(j, 1, n) {
            FOR(z, 1, k) {
                if (b[i][z] == - 1 || s[j][z] == - 1) continue;
                maxC[i][j] = max(maxC[i][j], s[j][z] - b[i][z]);
            }
        }
    }
}

bool check(double x) {

    vector<double> f(n + 1);
    FOR(t, 1, n) {
        FOR(u, 1, n) FOR(v, 1, n) {
            if (minD[u][v] == inf) continue;
            if (f[v] > f[u] + (double)x * minD[u][v] - maxC[u][v]) f[v] = f[u] + (double)x * minD[u][v] - maxC[u][v];
        }
    }
    REP(t, n) {
        FOR(u, 1, n) FOR(v, 1, n) {
            if (minD[u][v] == inf) continue;
            if (f[v] && f[v] > f[u] + (double)x * minD[u][v] - maxC[u][v]) return true;
        }
    }
    return false;
}

int32_t main() {
    fastio;

    cin >> n >> m >> k;
    b.assign(n + 1, vector<int>(k + 1));
    s.assign(n + 1, vector<int>(k + 1));
    FOR(i, 1, n) FOR(j, 1, k) cin >> b[i][j] >> s[i][j];
    adj.resize(n + 1);
    REP(i, m) {
        int u, v, w;
        cin >> u >> v >> w;
        adj[u].push_back({v, w});
    }
    minD.assign(n + 1, vector<int>(n + 1, inf));
    load_minDist();
    maxC.assign(n + 1, vector<int>(n + 1));
    load_maxCost();
    double l = 0;
    double r = inf;
    while (l + EPS <= r) {
        double mid = (l + r) / 2;
        if (check(mid)) l = mid;
        else r = mid;
    }
    cout << (int)(l + EPS * 2) << '\n';
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 12
Accepted
time: 65ms
memory: 5212kb

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
Wrong Answer
time: 57ms
memory: 3668kb

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:

1

result:

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

Subtask #2:

score: 21
Accepted

Test #14:

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

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: 7ms
memory: 3576kb

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: 3556kb

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: 3604kb

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: 5ms
memory: 3636kb

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: 1ms
memory: 3448kb

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: 7ms
memory: 3504kb

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: 7ms
memory: 3592kb

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: 9ms
memory: 3608kb

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: 8ms
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: 7ms
memory: 3544kb

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: 7ms
memory: 3632kb

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: 7ms
memory: 3520kb

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: 5ms
memory: 3600kb

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: 7ms
memory: 3480kb

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: 8ms
memory: 3536kb

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: 0ms
memory: 3524kb

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: 3ms
memory: 3592kb

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: 8ms
memory: 3540kb

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: 7ms
memory: 3612kb

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: 7ms
memory: 3668kb

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: 6ms
memory: 3496kb

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: 33
Accepted

Test #37:

score: 33
Accepted
time: 90ms
memory: 5204kb

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: 1ms
memory: 3460kb

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: 0
Accepted
time: 8ms
memory: 3568kb

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:

138919

result:

ok single line: '138919'

Test #40:

score: 0
Accepted
time: 9ms
memory: 3684kb

input:

50 100 100
714420219 664420219 670988077 620988077 749695455 699695455 567602634 546701549 630315751 580315751 548562478 510475293 734437437 684437437 517242293 467242293 712844065 662844065 530370481 480370481 584518044 534518044 780621679 730621679 542815120 533903899 599496563 549496563 709776870...

output:

2773

result:

ok single line: '2773'

Test #41:

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

input:

50 80 100
613124154 298784098 537389012 279713205 499689681 471314836 886103757 60087694 845068143 368855914 648389008 300242966 646640622 221676660 866330078 514509030 604069994 416492438 611394991 453739552 732469971 524033149 694292198 5271026 573810521 471002300 531489460 212864274 881123884 266...

output:

49797

result:

ok single line: '49797'

Test #42:

score: 0
Accepted
time: 87ms
memory: 5524kb

input:

100 9900 1000
986355298 343941451 748009505 157768582 549897631 353675832 784259651 71183802 455272137 239882644 688026841 125591164 861653505 535779783 761535420 360625660 485161701 275682287 548652543 525094271 577374254 540601357 586092427 379551990 490170545 79852082 804653532 513745338 55248752...

output:

2478

result:

ok single line: '2478'

Test #43:

score: 0
Accepted
time: 87ms
memory: 5516kb

input:

100 9900 1000
727914573 352681283 745159911 478069159 524736757 267716315 554533162 49659853 704220141 272866726 878406576 349556214 606558787 31608223 752128450 136602787 645580703 226343143 981500098 238380602 863321669 443495332 937077574 118463117 609547732 88002197 787077169 405900536 776842331...

output:

1330867

result:

ok single line: '1330867'

Test #44:

score: 0
Accepted
time: 54ms
memory: 3796kb

input:

100 100 100
289207 289207 384956 384956 229259 229259 546415 546415 171739 171739 282850 282850 221135 221135 16583 16583 370773 370773 119341 119341 426085 426085 440159 440159 253180 253180 529005 529005 428704 428704 211778 211778 309906 309906 325591 325591 156929 156929 288408 288408 422082 422...

output:

830

result:

ok single line: '830'

Test #45:

score: 0
Accepted
time: 83ms
memory: 5132kb

input:

100 500 900
370608755 370608755 394298561 394298561 477985939 477985939 312239957 312239957 742647608 742647608 346481586 346481586 535875402 535875402 711205883 711205883 538460115 538460115 399559367 399559367 716685729 716685729 631088306 631088306 420575105 420575105 418270029 418270029 45272598...

output:

2936107

result:

ok single line: '2936107'

Test #46:

score: 0
Accepted
time: 50ms
memory: 3776kb

input:

100 563 40
490783053 490783053 500616737 500616737 610816964 610816964 630654725 630654725 605493528 605493528 374238654 374238654 452823555 452823555 519705766 519705766 537548608 537548608 447518535 447518535 524316798 524316798 551017738 551017738 662639933 662639933 574991144 574991144 505436345...

output:

2420209

result:

ok single line: '2420209'

Test #47:

score: 0
Accepted
time: 53ms
memory: 3812kb

input:

100 100 100
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 100000000...

output:

100

result:

ok single line: '100'

Test #48:

score: 0
Accepted
time: 43ms
memory: 3904kb

input:

100 100 100
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 100000000...

output:

999999999

result:

ok single line: '999999999'

Test #49:

score: 0
Accepted
time: 57ms
memory: 3736kb

input:

100 596 40
358458945 358458945 331034157 331034157 349074033 349074033 344044690 344044690 485167401 485167401 734094465 734094465 530915559 530915559 589250413 589250413 256795508 256795508 489343536 489343536 534470289 534470289 267233079 267233079 482426953 482426953 626623725 626623725 648411549...

output:

2394068

result:

ok single line: '2394068'

Subtask #4:

score: 0
Skipped

Dependency #1:

0%