Problem wormholes
User r1r2r3r4
Submission Time 2025-08-13 16:04:18
Score 0
Max Time N/A
Max Memory N/A

Compile Error

wormholes.cpp: In function ‘int time(int&)’:
wormholes.cpp:9:40: error: cannot bind non-const lvalue reference of type ‘int&’ to an rvalue of type ‘int’
9 | return min(time(out[x]), time(x-1))+1;
| ~^~
wormholes.cpp:5:15: note: initializing argument 1 of ‘int time(int&)’
5 | int time(int& x) {
| ~~~~~^
wormholes.cpp:11:23: error: cannot bind non-const lvalue reference of type ‘int&’ to an rvalue of type ‘int’
11 | else return time(x-1)+1;
| ~^~
wormholes.cpp:5:15: note: initializing argument 1 of ‘int time(int&)’
5 | int time(int& x) {
| ~~~~~^
wormholes.cpp: In function ‘int main()’:
wormholes.cpp:29:19: error: cannot bind non-const lvalue reference of type ‘int&’ to an rvalue of type ‘int’
29 | cout << time(n-1);
| ~^~
wormholes.cpp:5:15: note: initializing argument