Submission details
Task:Investing
Sender:Makkara
Submission time:2025-11-08 16:59:27 +0200
Language:C++ (C++17)
Status:READY
Result:
Test results
testverdicttime
#10.00 sdetails
#20.00 sdetails
#30.01 sdetails
#40.00 sdetails
#50.00 sdetails
#60.00 sdetails
#70.00 sdetails
#8ACCEPTED0.00 sdetails
#90.00 sdetails
#10ACCEPTED0.00 sdetails
#11ACCEPTED0.00 sdetails
#12ACCEPTED0.00 sdetails
#130.00 sdetails
#14ACCEPTED0.00 sdetails
#150.00 sdetails
#16ACCEPTED0.00 sdetails
#170.00 sdetails
#180.00 sdetails
#190.00 sdetails
#200.01 sdetails
#210.01 sdetails
#220.03 sdetails
#23ACCEPTED0.01 sdetails
#240.01 sdetails
#250.01 sdetails
#260.03 sdetails
#27ACCEPTED0.03 sdetails
#280.00 sdetails
#290.03 sdetails
#30ACCEPTED0.01 sdetails
#31ACCEPTED0.03 sdetails
#32ACCEPTED0.00 sdetails
#33ACCEPTED0.03 sdetails
#34ACCEPTED0.01 sdetails
#350.01 sdetails
#36ACCEPTED0.01 sdetails
#37ACCEPTED0.01 sdetails
#380.01 sdetails

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:22:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |       for(int j=0; j<g[v].size(); j++) {
      |                    ~^~~~~~~~~~~~
input/code.cpp:31:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |       for(int j=0; j<g[v].size(); j++) {
      |                    ~^~~~~~~~~~~~

Code

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

#define INF ((long long) (1e15))

int main() {
  int n, m, a, b;
  cin >> n >> m >> a >> b;
  vector <int> g[n+1];
  vector <long long> w[n+1];
  int x[m], y[m];
  long long cost[n+1], z[m];
  for(int i=0; i<m; i++) {
    cin >> x[i] >> y[i] >> z[i]; z[i] = -z[i];
    g[x[i]].push_back(y[i]);
    w[x[i]].push_back(z[i]);
  }
  for(int i=0; i<=n; i++) cost[i] = INF;
  cost[a] = 0;
  for(int i=1; i<n; i++) {
    for(int v = 1; v <= n; v++) {
      for(int j=0; j<g[v].size(); j++) {
        int u = g[v][j];
        long long ww = w[v][j];
        cost[u] = min(cost[u], cost[v] + ww);
      }
    }
  }
  bool f1 = false, f2 = false;
  for(int v = 1; v <= n; v++) {
      for(int j=0; j<g[v].size(); j++) {
        int u = g[v][j];
        long long ww = w[v][j];
        if(cost[u] > cost[v] + ww) {
          cost[u] = cost[v] + ww;
          if (u == a) f1 = true;
          if(u == b) f2 = true;
        }
      }
  }
  
  if(cost[b] < -1e12) cout << "IMPOSSIBLE" << endl;
  else if((f1 || f2) || cost[a] > 0) cout << "INFINITE MONEY GLITCH" << endl;
  else cout << cost[b] << endl;
  
  return 0;
}

Test details

Test 1

Verdict:

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

correct output
100

user output
-100

Feedback: Incorrect character on line 1 col 1: expected "100", got "-100"

Test 2

Verdict:

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

correct output
IMPOSSIBLE

user output
1000000000000000

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

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
1000000000000000

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

Test 4

Verdict:

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

correct output
-176

user output
176

Feedback: Incorrect character on line 1 col 1: expected "-176", got "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
98

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

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
-357

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

Test 7

Verdict:

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

correct output
IMPOSSIBLE

user output
INFINITE MONEY GLITCH

Feedback: Output is longer than expected

Test 8

Verdict: ACCEPTED

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

correct output
INFINITE MONEY GLITCH

user output
INFINITE MONEY GLITCH

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
79

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

Test 10

Verdict: ACCEPTED

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

correct output
INFINITE MONEY GLITCH

user output
INFINITE MONEY GLITCH

Test 11

Verdict: ACCEPTED

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

correct output
0

user output
0

Test 12

Verdict: ACCEPTED

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

correct output
INFINITE MONEY GLITCH

user output
INFINITE MONEY GLITCH

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
93

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

Test 14

Verdict: ACCEPTED

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

correct output
INFINITE MONEY GLITCH

user output
INFINITE MONEY GLITCH

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
61

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

Test 16

Verdict: ACCEPTED

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

correct output
INFINITE MONEY GLITCH

user output
INFINITE MONEY GLITCH

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
-300

Feedback: Output is shorter than expected

Test 18

Verdict:

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

correct output
300

user output
-300

Feedback: Incorrect character on line 1 col 1: expected "300", got "-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
13

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

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
-11333

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

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
999999999999892

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

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
-2015

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

Test 23

Verdict: ACCEPTED

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

correct output
INFINITE MONEY GLITCH

user output
INFINITE MONEY GLITCH

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
-4259

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

Test 25

Verdict:

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

correct output
IMPOSSIBLE

user output
1000000000000000

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

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
-5168

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

Test 27

Verdict: ACCEPTED

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

correct output
INFINITE MONEY GLITCH

user output
INFINITE MONEY GLITCH

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
115

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

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
251

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

Test 30

Verdict: ACCEPTED

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

correct output
INFINITE MONEY GLITCH

user output
INFINITE MONEY GLITCH

Test 31

Verdict: ACCEPTED

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

correct output
INFINITE MONEY GLITCH

user output
INFINITE MONEY GLITCH

Test 32

Verdict: ACCEPTED

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

correct output
INFINITE MONEY GLITCH

user output
INFINITE MONEY GLITCH

Test 33

Verdict: ACCEPTED

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

correct output
INFINITE MONEY GLITCH

user output
INFINITE MONEY GLITCH

Test 34

Verdict: ACCEPTED

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

correct output
INFINITE MONEY GLITCH

user output
INFINITE MONEY GLITCH

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
-299100

Feedback: Output is shorter than expected

Test 36

Verdict: ACCEPTED

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

correct output
INFINITE MONEY GLITCH

user output
INFINITE MONEY GLITCH

Test 37

Verdict: ACCEPTED

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

correct output
INFINITE MONEY GLITCH

user output
INFINITE MONEY GLITCH

Test 38

Verdict:

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

correct output
299100

user output
-299100

Feedback: Incorrect character on line 1 col 1: expected "299100", got "-299100"