You are viewing a single comment's thread. Return to all comments →
Passed all cases but these test cases seem very weak. Anybody with some solid test cases?
int bfs(vector<int> adj[], int start, int n, vector<long> ids, int val){ queue<int> q; vector<bool> visited(n , false); vector<int> level(n, -1); q.push(start); visited[start] = true; level[start] = 0; while(!q.empty()){ int s = q.front(); q.pop(); for(auto x : adj[s]){ if(!visited[x]){ q.push(x); visited[x] = true; level[x] = level[s] + 1; if(ids[x] == val) return level[x]; } } } return -1; } int findShortest(int graph_nodes, vector<int> graph_from, vector<int> graph_to, vector<long> ids, int val) { vector<int> adj[graph_nodes]; for(int i = 0; i < graph_from.size(); i++){ int u = graph_from[i] - 1; int v = graph_to[i] - 1; adj[u].push_back(v); adj[v].push_back(u); } int min = INT_MAX; for(int i = 0; i < graph_nodes; i++){ if(ids[i] == val){ int cur = bfs(adj, i, graph_nodes, ids, val); if(min > cur && cur != -1) min = cur; } } if(min == INT_MAX) min = -1; return min; }
Try this one (it's the output from the generator in https://www.hackerrank.com/challenges/find-the-nearest-clone/forum/comments/592337 ):
http://etotheipiplusone.com/projects/hackerrank/find-the-nearest-clone-testcase-large-0.txt
11MB download; 1'000'000 nodes and 1'000'000 edges, so obeys the problem constraints.
It should be easy to generate similarly tough, but less "predictable" ones, too; in fact, here's another, slightly crazier one:
http://etotheipiplusone.com/projects/hackerrank/find-the-nearest-clone-testcase-large-09.txt
or
http://etotheipiplusone.com/projects/hackerrank/find-the-nearest-clone-testcase-large-14.txt
This one is the most evil one I've created so far :)
http://vps2.etotheipiplusone.com:30176/public_html/hackerrank/find-the-nearest-clone-testcase-large-15.txt
Seems like cookies are disabled on this browser, please enable them to open this website
I agree to HackerRank's Terms of Service and Privacy Policy.
Find the nearest clone
You are viewing a single comment's thread. Return to all comments →
Passed all cases but these test cases seem very weak. Anybody with some solid test cases?
Try this one (it's the output from the generator in https://www.hackerrank.com/challenges/find-the-nearest-clone/forum/comments/592337 ):
http://etotheipiplusone.com/projects/hackerrank/find-the-nearest-clone-testcase-large-0.txt
11MB download; 1'000'000 nodes and 1'000'000 edges, so obeys the problem constraints.
It should be easy to generate similarly tough, but less "predictable" ones, too; in fact, here's another, slightly crazier one:
http://etotheipiplusone.com/projects/hackerrank/find-the-nearest-clone-testcase-large-09.txt
or
http://etotheipiplusone.com/projects/hackerrank/find-the-nearest-clone-testcase-large-14.txt
This one is the most evil one I've created so far :)
http://vps2.etotheipiplusone.com:30176/public_html/hackerrank/find-the-nearest-clone-testcase-large-15.txt