Submission #126311

# Submission time Handle Problem Language Result Execution time Memory
126311 2019-07-07T11:37:33 Z eriksuenderhauf 007 (CEOI14_007) C++11
0 / 100
342 ms 44896 KB
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define mem(a,v) memset((a), (v), sizeof (a))
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int i = 0; i < (n); i++) ni(a[i])
#define nal(a, n) for (int i = 0; i < (n); i++) nl(a[i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pil pair<int, long long>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vil vector<pil>
#define vll vector<pll>
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int MAXN = 1e6 + 5;
const double eps = 1e-9;
int n, m, dp[MAXN];
vi adj[MAXN];

pii bfs(int src, int x, int y) {
	deque<int> pq;
	mem(dp, 0x3f);
	dp[src] = 0;
	pq.pb(src);
	while (!pq.empty()) {
		int u = pq.front(); pq.pop_front();
		for (int v: adj[u]) {
			if (dp[v] != 1061109567)
				continue;
			dp[v] = dp[u] + 1;
			pq.pb(v);
		}
	}
	return mp(dp[x], dp[y]);
}

int main() {
	int s, d, a, b;
	scanf("%d %d %d %d %d %d", &n, &m, &s, &d, &a, &b);
	for (int i = 1; i <= m; i++) {
		int u, v;
		scanf("%d %d", &u, &v);
		adj[u].pb(v);
		adj[v].pb(u);
	}
	pii a1 = bfs(s, a, b);
	pii a2 = bfs(d, a, b);
	int ans = min(a2.fi - a1.fi, a2.se - a1.se);
	if (ans < 0) ans = -1;
	pri(ans);
    return 0;
}

Compilation message

007.cpp: In function 'int main()':
007.cpp:59:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d %d %d %d", &n, &m, &s, &d, &a, &b);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
007.cpp:62:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &u, &v);
   ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 27 ms 27768 KB Output is correct
2 Correct 27 ms 27772 KB Output is correct
3 Correct 27 ms 27768 KB Output is correct
4 Incorrect 29 ms 27896 KB Output isn't correct
5 Incorrect 27 ms 27768 KB Output isn't correct
6 Correct 28 ms 27768 KB Output is correct
7 Correct 32 ms 27768 KB Output is correct
8 Incorrect 29 ms 27768 KB Output isn't correct
9 Correct 27 ms 27768 KB Output is correct
10 Correct 28 ms 27768 KB Output is correct
11 Correct 27 ms 27768 KB Output is correct
12 Incorrect 28 ms 27816 KB Output isn't correct
13 Correct 28 ms 27768 KB Output is correct
14 Incorrect 27 ms 27772 KB Output isn't correct
15 Correct 28 ms 27768 KB Output is correct
16 Incorrect 28 ms 27768 KB Output isn't correct
17 Incorrect 28 ms 27768 KB Output isn't correct
18 Incorrect 28 ms 27768 KB Output isn't correct
19 Correct 28 ms 27768 KB Output is correct
20 Correct 28 ms 27768 KB Output is correct
21 Correct 27 ms 27768 KB Output is correct
22 Correct 33 ms 27768 KB Output is correct
23 Correct 27 ms 27768 KB Output is correct
24 Incorrect 27 ms 27768 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 55 ms 29588 KB Output is correct
2 Incorrect 65 ms 30328 KB Output isn't correct
3 Correct 55 ms 29564 KB Output is correct
4 Incorrect 68 ms 30328 KB Output isn't correct
5 Correct 54 ms 29404 KB Output is correct
6 Correct 65 ms 29564 KB Output is correct
7 Correct 60 ms 29788 KB Output is correct
8 Correct 57 ms 29816 KB Output is correct
9 Incorrect 71 ms 30712 KB Output isn't correct
10 Correct 206 ms 39164 KB Output is correct
11 Incorrect 94 ms 31608 KB Output isn't correct
12 Correct 116 ms 32784 KB Output is correct
13 Incorrect 121 ms 31992 KB Output isn't correct
14 Correct 85 ms 31224 KB Output is correct
15 Correct 114 ms 32888 KB Output is correct
16 Correct 117 ms 33024 KB Output is correct
17 Correct 105 ms 32504 KB Output is correct
18 Incorrect 124 ms 32616 KB Output isn't correct
19 Correct 153 ms 34900 KB Output is correct
20 Incorrect 255 ms 40668 KB Output isn't correct
21 Incorrect 156 ms 34808 KB Output isn't correct
22 Correct 135 ms 33884 KB Output is correct
23 Correct 145 ms 34680 KB Output is correct
24 Correct 145 ms 34552 KB Output is correct
25 Incorrect 140 ms 34308 KB Output isn't correct
26 Correct 134 ms 34040 KB Output is correct
27 Correct 154 ms 34768 KB Output is correct
28 Correct 206 ms 34936 KB Output is correct
29 Correct 185 ms 36920 KB Output is correct
30 Incorrect 270 ms 41352 KB Output isn't correct
31 Incorrect 177 ms 35964 KB Output isn't correct
32 Correct 148 ms 34808 KB Output is correct
33 Correct 152 ms 35064 KB Output is correct
34 Incorrect 178 ms 35308 KB Output isn't correct
35 Incorrect 158 ms 34900 KB Output isn't correct
36 Incorrect 150 ms 35292 KB Output isn't correct
37 Correct 177 ms 36344 KB Output is correct
38 Correct 174 ms 36088 KB Output is correct
39 Correct 207 ms 36188 KB Output is correct
40 Incorrect 242 ms 39848 KB Output isn't correct
41 Correct 342 ms 44896 KB Output is correct