×

# The Great Escape: Runtime Error

 0 I tried solving The Great Escape on the INOI server: http://opc.iarcs.org.in/index.php/problems/GREATESC I used a simple BFS to find the minimum number of jumps. But my code is showing segmentation fault in the last test case. Can anyone one point out my mistake? My code: #include #include #include #include using namespace std; vector adjlist[3500]; queue bfs; int main() { int n,m; cin >> n >> m; int a,b; while(m--) { cin >> a >> b; a--; b--; adjlist[a].push_back(b); adjlist[b].push_back(a); } int s,t; cin >> s >> t; s--; t--; int v[n]; memset(v,-1,sizeof(v)); v[s] = 0; bfs.push(s); while(!bfs.empty()) { int node = bfs.front(); bfs.pop(); int d = v[node]; for(unsigned int i = 0;i < adjlist[node].size();i++) { int node2 = adjlist[node][i]; if(v[node2] == -1) { v[node2] = d+1; bfs.push(node2); } } } if(v[t] == -1) cout << 0 << endl; else cout << v[t] << endl; return 0; }  asked 10 Jan '15, 10:51 6★ketanhwr 1.9k●3●18●44 accept rate: 15% It might be a problem with the testdata, but maybe not. I have the same issue. (10 Jan '15, 11:45) superty3★ But many people have got 100 :-/ (10 Jan '15, 13:13) ketanhwr6★ I have the same problem too! (10 Jan '15, 13:19) sandy9992★ They would've looked at the test cases I suppose. A lot of number of iarcs problems seem to have issues (10 Jan '15, 17:57) superty3★ I asked someone. The test data is faulty. Just check if m = 641902. If it is then output 0 and exit (although the correct answer is 2800). For other m, run the normal program. (10 Jan '15, 22:29) ketanhwr6★ Yeah, as I said the test cases must be faulty. IMO it's not of any use to do these kind of modifications, you don't learn anything, just get some points in IARCS site which is of no purpose. (11 Jan '15, 10:58) superty3★ @superty Are the test cases faulty for DEVIOUS as well? I am getting only 80 points. (11 Jan '15, 17:10) sandy9992★ I got 80 as well. In future you can check in my profile: http://opc.iarcs.org.in/index.php/users/Superty (12 Jan '15, 00:21) superty3★ showing 5 of 8 show all

 0 Well I'm not so sure about the test cases being faulty. I implemented a simple BFS and it gets 100 on the grader with no issues. In case you want to check - http://pastebin.com/JMmvUXJ2 answered 04 Feb '15, 18:08 3★ishoo 5●1●4 accept rate: 0% They've now fixed the test data. The same program which failed previously works now. (not that the last comment on this thread is dated 23rd Jan) (04 Feb '15, 18:48) superty3★
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×545
×399
×109
×13

question asked: 10 Jan '15, 10:51

question was seen: 1,477 times

last updated: 04 Feb '15, 18:50