C++ AND Java-> Runtime error on codeforces but working on my PC

Revision en1, by OneClickAC, 2017-02-17 20:53:48

Hello codeforces community :)

PROBLEM 1: C++ related

I am beginner who has recently started learning about graphs and for that I was trying to solve out this dfs problem (http://codeforces.com/problemset/problem/115/A) ..

I wrote a code in C++ which is working fine on my laptop but is giving a runtime error on codeforces .. Can anyone help me out why this is happening and how to sort it out and can someone also list out the possible reasons when and why this kind of error happens , as it will help me in future ... :)

Code Link -> http://pastebin.com/54hFqrMC

PROBLEM 2: Java related

Well my second problem is also related to same question but this time , I need help of people who code in java. Basically , When my solution was not working , I tried to write code for the problem in Java . This time , problem is not about runtime error but lack of knowledge that I am having about how to use iterators and collection frameworks in Java . I am attaching a picture of error I am getting on IntelliJ IDEA and also providing my code . Please do help me out with these 2 problems . :)

Code Link -> http://pastebin.com/42sekm53 Thanks in advance to the best competitive coding community in the world :) ..

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English OneClickAC 2017-02-17 20:53:48 1301 Initial revision (published)