+ 1
Stack and function calls in c++ and python
I am new to python.When i implement a dfs code using c++ it works fine but in python it brings me a runtime error.i expect that it might be because of the stack .is there is a different between the way the stack works and function calls in c++ and python.Thanks very much in advance.
31 ответ
+ 1
what do your python code look like and what is it supposed to do, I might be able to just write out what you need to type/change
+ 1
ok, I will figure it out asap
+ 1
for i in range (1,n+1):
manager[i]=int(input())
for i in range (1,n+1):
what is the 1,n+1 supposed to do
+ 1
no, I think I have it working I will tell you soon
+ 1
you are welcome! I enjoy helping people!
0
define stack
0
it was a solution for a problem in codeforces .do you want me to include my c++/python code?
0
yes! please!
0
that is the problem http://codeforces.com/problemset/problem/115/A
that is how i solved it in c++ http://codeforces.com/contest/115/submission/29024765
and that is the python code http://codeforces.com/contest/115/submission/29024623
it brings a runtime error although it is identical to the c++ code that is accepted
0
to loop from 1 to n
0
ok, in python, you would just put
x = n+1
for i in x
0
also what are the input for?
0
sorry meant inputs, stupid auto correct
0
i tried range(1,n+1) in another code and it worked and that is the code
https://code.sololearn.com/cGKytcP96kSC/?ref=app
for input() i used it to get input from the user
0
yes, I understand the input reason.
is "n" number of employees
is "manager" number of managers
also you had input set up as an int not a string.
solo learn also does not have the best interpreter, I'm using python 3.6.1 so I have the most accurate of them.
0
n is the number of employees i set it to an integer to use it as a number.manager is a list containing the manager of each employee
0
it had a problem with that
0
it only counted 1 to n and didn't give the error
I will do my best to make it do that
0
also, a runtime error means it took to long to respond
0
i think if it took long time it will bring time limit exceeded .also in test 39 n (the number of employees)was 2000 the same number in test case 40 on which the code failed so i don't think it is a matter of time