#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
#include "stations.h"
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
#define rrep(i,a,b) for(int i=int(a);i>int(b);i--)
#define trav(a,v) for(auto& a: v)
#define sz(v) v.size()
#define all(v) v.begin(),v.end()
#define vi vector<int>
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const long long inf = 2e9;
using namespace std;
vector<int> label(int n, int k, std::vector<int> u, std::vector<int> v) {
vector<int> ans(n);
rep(i, 0, n)ans[i] = i;
return ans;
}
bool dfs(ll cur, ll wanted, vector<bool>& visited) {
if (visited[cur])return 0;
if (cur == wanted)return 1;
if (cur > 1000)return 0;
visited[cur] = 1;
bool ans = 0;
ans = ans || dfs(cur*2+1, wanted, visited);
ans = ans || dfs(cur*2+2, wanted, visited);
if(cur!=0)ans = ans || dfs((cur - 1) / 2, wanted, visited);
return ans;
}
int find_next_station(int s, int t, vector<int> c) {
vector<bool> visited(1001);
visited[s] = 1;
ll ans = -1;
trav(a, c) {
if (dfs(a, t, visited)) {
ans = a;
break;
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
851 ms |
496 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
545 ms |
400 KB |
Output is correct |
2 |
Correct |
876 ms |
488 KB |
Output is correct |
3 |
Correct |
1014 ms |
472 KB |
Output is correct |
4 |
Correct |
841 ms |
488 KB |
Output is correct |
5 |
Correct |
948 ms |
488 KB |
Output is correct |
6 |
Correct |
979 ms |
472 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
834 ms |
492 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1184 ms |
528 KB |
Output is correct |
2 |
Incorrect |
983 ms |
488 KB |
Wrong query response. |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
934 ms |
484 KB |
Wrong query response. |
2 |
Halted |
0 ms |
0 KB |
- |