Submission details
Task:Investing
Sender:All dO(n³)
Submission time:2025-11-08 16:59:20 +0200
Language:C++ (C++20)
Status:READY
Result:
Test results
testverdicttime
#1ACCEPTED0.00 sdetails
#2ACCEPTED0.00 sdetails
#30.00 sdetails
#4ACCEPTED0.00 sdetails
#50.00 sdetails
#60.00 sdetails
#7ACCEPTED0.00 sdetails
#80.00 sdetails
#90.00 sdetails
#100.00 sdetails
#110.00 sdetails
#120.00 sdetails
#130.00 sdetails
#140.00 sdetails
#150.00 sdetails
#160.00 sdetails
#170.00 sdetails
#18ACCEPTED0.00 sdetails
#190.01 sdetails
#200.01 sdetails
#210.01 sdetails
#220.04 sdetails
#230.01 sdetails
#240.01 sdetails
#25ACCEPTED0.01 sdetails
#260.04 sdetails
#270.04 sdetails
#280.01 sdetails
#290.04 sdetails
#300.01 sdetails
#310.04 sdetails
#320.01 sdetails
#330.04 sdetails
#340.01 sdetails
#350.01 sdetails
#360.01 sdetails
#370.01 sdetails
#38ACCEPTED0.01 sdetails

Compiler report

input/code.cpp: In function 'void relaxCycle()':
input/code.cpp:11:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<std::pair<int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     for (int i = 1; i < adj.size(); i++) {
      |                     ~~^~~~~~~~~~~~
input/code.cpp:12:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |         for (int j = 0; j < adj[i].size(); j++) {
      |                         ~~^~~~~~~~~~~~~~~

Code

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


const long long INF = -__LONG_LONG_MAX__;

vector<long long> relax;
vector<vector<pair<int, long long>>> adj;

void relaxCycle() {
    for (int i = 1; i < adj.size(); i++) {
        for (int j = 0; j < adj[i].size(); j++) {
            auto p = adj[i][j];
            if (relax[p.first] < relax[i] + p.second) {
                relax[p.first] = relax[i] + p.second;
            }
        }
    }
}

int main () {
    int n, m, a, b;
    cin >> n >> m >> a >> b;

    relax = vector<long long>(n+1, INF);
    relax[a] = 0;
    adj = vector<vector<pair<int, long long>>>(n + 1);

    for (int i = 0; i < m; i++) {
        int v, u, w;
        cin >> v >> u >> w;
        adj[v].push_back(make_pair(u, w));
    }

    for (int i = 0; i < n; i++) {
        relaxCycle();
    }

    auto ans = relax[b];
    if (ans == INF) {
        cout << "IMPOSSIBLE";
        return 0;
    }
    relaxCycle();
    auto asd = relax[b];
    if (asd > ans) {
        cout << "INFINITE MONEY GLITCH";
    } else {
        cout << ans;
    }
    return 0;
}

Test details

Test 1

Verdict: ACCEPTED

input
3 3 1 2
3 2 200
1 2 -100
1 3 -100

correct output
100

user output
100

Test 2

Verdict: ACCEPTED

input
5 5 4 3
5 2 -62
5 4 -93
3 1 -223
2 1 132
...

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 3

Verdict:

input
5 5 5 3
5 1 72
1 2 269
4 3 -285
4 1 -48
...

correct output
IMPOSSIBLE

user output
9223372036854775601

Feedback: Incorrect character on line 1 col 1: expected "IMPOSSIBLE", got "922337203685..."

Test 4

Verdict: ACCEPTED

input
5 5 3 4
3 4 -176
4 1 -289
5 1 -228
2 5 125
...

correct output
-176

user output
-176

Test 5

Verdict:

input
5 10 5 4
4 2 -181
1 4 157
1 3 111
1 5 7
...

correct output
-98

user output
9223372036854775521

Feedback: Incorrect character on line 1 col 1: expected "-98", got "922337203685..."

Test 6

Verdict:

input
5 10 2 5
4 5 -245
4 5 138
4 5 215
3 2 -165
...

correct output
357

user output
9223372036854775712

Feedback: Incorrect character on line 1 col 1: expected "357", got "922337203685..."

Test 7

Verdict: ACCEPTED

input
5 10 1 5
3 4 136
3 1 -130
2 4 -280
5 4 -249
...

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 8

Verdict:

input
5 10 4 1
3 1 -2
5 1 215
4 2 166
4 1 -279
...

correct output
INFINITE MONEY GLITCH

user output
9223372036854775807

Feedback: Output is shorter than expected

Test 9

Verdict:

input
5 10 5 1
1 5 -224
1 4 -220
4 2 -1
4 5 -214
...

correct output
-79

user output
9223372036854775761

Feedback: Incorrect character on line 1 col 1: expected "-79", got "922337203685..."

Test 10

Verdict:

input
5 10 2 1
1 4 -299
1 2 -39
4 5 81
4 1 -56
...

correct output
INFINITE MONEY GLITCH

user output
9223372036854775536

Feedback: Output is shorter than expected

Test 11

Verdict:

input
5 10 4 4
5 3 -174
5 2 -46
5 1 -210
2 1 -80
...

correct output
0

user output
9223372036854775575

Feedback: Incorrect character on line 1 col 1: expected "0", got "922337203685..."

Test 12

Verdict:

input
5 10 4 2
4 5 -218
4 2 -30
4 1 -218
2 4 -64
...

correct output
INFINITE MONEY GLITCH

user output
9223372036854775715

Feedback: Output is shorter than expected

Test 13

Verdict:

input
10 30 9 7
3 8 39
4 8 -39
4 6 -38
10 7 -178
...

correct output
-93

user output
9223372036854775673

Feedback: Incorrect character on line 1 col 1: expected "-93", got "922337203685..."

Test 14

Verdict:

input
10 30 3 10
3 6 -1
3 8 -300
3 9 -143
7 2 -5
...

correct output
INFINITE MONEY GLITCH

user output
9223372036854775557

Feedback: Output is shorter than expected

Test 15

Verdict:

input
10 30 7 8
8 4 -53
5 3 -87
5 1 -266
5 2 -277
...

correct output
-61

user output
9223372036854775799

Feedback: Incorrect character on line 1 col 1: expected "-61", got "922337203685..."

Test 16

Verdict:

input
10 30 8 9
2 9 -37
5 3 -259
5 2 -222
7 1 -184
...

correct output
INFINITE MONEY GLITCH

user output
9223372036854775772

Feedback: Output is shorter than expected

Test 17

Verdict:

input
4 5 3 1
4 2 -107
4 1 -300
2 4 108
3 1 300
...

correct output
INFINITE MONEY GLITCH

user output
9223372036854775617

Feedback: Output is shorter than expected

Test 18

Verdict: ACCEPTED

input
4 4 3 2
1 4 -177
4 1 178
3 2 300
3 4 -300

correct output
300

user output
300

Test 19

Verdict:

input
100 1000 95 59
17 33 -154
17 32 68
17 65 71
17 9 -284
...

correct output
-13

user output
9223372036854775807

Feedback: Incorrect character on line 1 col 1: expected "-13", got "922337203685..."

Test 20

Verdict:

input
100 10000 95 70
49 84 -186
49 65 120
49 76 -38
49 66 27
...

correct output
11333

user output
9223372036854775807

Feedback: Incorrect character on line 1 col 1: expected "11333", got "922337203685..."

Test 21

Verdict:

input
1000 1000 942 532
211 103 0
65 459 266
132 809 -167
538 228 -206
...

correct output
IMPOSSIBLE

user output
9223372036854775718

Feedback: Incorrect character on line 1 col 1: expected "IMPOSSIBLE", got "922337203685..."

Test 22

Verdict:

input
1000 10000 356 204
831 540 180
77 237 -170
77 284 -62
77 431 -233
...

correct output
2015

user output
9223372036854775753

Feedback: Incorrect character on line 1 col 1: expected "2015", got "922337203685..."

Test 23

Verdict:

input
100 1000 43 74
7 83 101
7 71 -207
7 14 76
83 71 235
...

correct output
INFINITE MONEY GLITCH

user output
9223372036854775793

Feedback: Output is shorter than expected

Test 24

Verdict:

input
100 10000 65 38
49 17 114
49 15 -56
49 50 -139
49 77 205
...

correct output
4259

user output
9223372036854775798

Feedback: Incorrect character on line 1 col 1: expected "4259", got "922337203685..."

Test 25

Verdict: ACCEPTED

input
1000 1000 130 119
306 321 288
250 624 58
724 994 193
924 126 271
...

correct output
IMPOSSIBLE

user output
IMPOSSIBLE

Test 26

Verdict:

input
1000 10000 520 842
992 359 30
992 751 -79
992 473 86
992 132 184
...

correct output
5168

user output
9223372036854775801

Feedback: Incorrect character on line 1 col 1: expected "5168", got "922337203685..."

Test 27

Verdict:

input
1000 10000 954 5
95 364 229
95 386 -23
95 516 40
95 385 188
...

correct output
INFINITE MONEY GLITCH

user output
9223372036854775803

Feedback: Output is shorter than expected

Test 28

Verdict:

input
100 1000 10 44
87 45 -54
87 5 -174
87 43 -45
87 54 -72
...

correct output
-115

user output
9223372036854775776

Feedback: Incorrect character on line 1 col 1: expected "-115", got "922337203685..."

Test 29

Verdict:

input
1000 10000 216 836
503 408 -244
438 4 -245
438 351 -210
438 797 -80
...

correct output
-251

user output
9223372036854775688

Feedback: Incorrect character on line 1 col 1: expected "-251", got "922337203685..."

Test 30

Verdict:

input
100 1000 35 52
81 36 -69
81 19 -271
81 87 -78
86 9 -119
...

correct output
INFINITE MONEY GLITCH

user output
9223372036854775687

Feedback: Output is shorter than expected

Test 31

Verdict:

input
1000 10000 237 361
274 53 -54
274 678 -68
723 853 -191
723 858 -86
...

correct output
INFINITE MONEY GLITCH

user output
9223372036854775750

Feedback: Output is shorter than expected

Test 32

Verdict:

input
100 1000 54 13
35 66 -59
35 92 -229
35 28 -211
35 58 -232
...

correct output
INFINITE MONEY GLITCH

user output
9223372036854775782

Feedback: Output is shorter than expected

Test 33

Verdict:

input
1000 10000 230 928
94 30 -61
94 594 -43
94 338 -123
827 422 -146
...

correct output
INFINITE MONEY GLITCH

user output
9223372036854775761

Feedback: Output is shorter than expected

Test 34

Verdict:

input
1000 1001 917 438
494 421 -150
494 917 -300
421 494 151
998 438 300
...

correct output
INFINITE MONEY GLITCH

user output
-9223372036854476856

Feedback: Output is shorter than expected

Test 35

Verdict:

input
1000 1001 183 711
197 383 -109
197 711 -300
383 197 110
570 711 300
...

correct output
INFINITE MONEY GLITCH

user output
9223372036854775617

Feedback: Output is shorter than expected

Test 36

Verdict:

input
1000 1001 43 622
622 786 -300
983 786 -73
983 43 -300
786 983 74
...

correct output
INFINITE MONEY GLITCH

user output
299100

Feedback: Output is shorter than expected

Test 37

Verdict:

input
1000 1001 116 939
320 700 -51
320 734 -300
700 320 52
425 939 300
...

correct output
INFINITE MONEY GLITCH

user output
-9223372036854513557

Feedback: Output is shorter than expected

Test 38

Verdict: ACCEPTED

input
1000 1000 7 836
973 309 79
309 973 -78
56 836 300
489 56 300
...

correct output
299100

user output
299100