Submission #110515

# Submission time Handle Problem Language Result Execution time Memory
110515 2019-05-11T05:29:30 Z ckodser 007 (CEOI14_007) C++14
0 / 100
485 ms 140748 KB
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
const int N = 1000006;
int n, m, a, b, s1, s2, D[2][N], F[N], P[N];
vector < int > vec[N], Adj[N];
inline void BFS(int st, int w, int tp = 0)
{
	queue < int > qu;
	qu.push(st); D[w][st] = 0;
	while (qu.size())
	{
		int v = qu.front();
		qu.pop();
		if (tp) vec[D[w][v]].pb(v);
		for (int &u : Adj[v])
			if (D[w][u] == -1)
				D[w][u] = D[w][v] + 1, qu.push(u);
	}
}
inline bool Check(int s, int t)
{
	if (D[0][t] < D[0][s] || D[1][t] < D[1][s])
		return 0;
	if (D[0][s] < D[0][t] || D[1][s] < D[1][t])
		return 1;
	return (F[s] <= F[t]);
}
inline bool CMP(int i, int j)
{
	return (D[0][i] <= D[0][j]);
}
int main()
{
	scanf("%d%d%d%d%d%d", &n, &m, &s1, &s2, &a, &b);
	for (int i = 0; i < m; i++)
	{
		int v, u;
		scanf("%d%d", &v, &u);
		Adj[v].pb(u);
		Adj[u].pb(v);
	}
	memset(D, -1, sizeof(D));
	BFS(s2, 0, 1);
	memset(D, -1, sizeof(D));
	BFS(a, 0); BFS(b, 1);
	memset(F, 63, sizeof(F));
	for (int i = 1; i <= n; i++)
		P[i] = i;
	sort(P + 1, P + n + 1, CMP);
	for (int i = 1; i <= n; i++)
	{
		int v = P[i];
		if (D[0][v] == D[1][v])
		{
			F[v] = D[0][v];
			for (int u : Adj[v])
				if (D[0][v] == D[0][u] + 1 && D[1][v] == D[1][u] + 1)
					F[v] = min(F[v], F[u]);
		}
	}
	for (int i = 0; ; i ++)
		for (int v : vec[i])
			if (!Check(s1, v))
				return !printf("%d\n", i - 1);
	return 0;
}

Compilation message

007.cpp: In function 'int main()':
007.cpp:35: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, &s1, &s2, &a, &b);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
007.cpp:39:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &v, &u);
   ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 60 ms 59000 KB Output is correct
2 Correct 59 ms 59000 KB Output is correct
3 Correct 56 ms 59000 KB Output is correct
4 Correct 54 ms 59000 KB Output is correct
5 Correct 57 ms 59000 KB Output is correct
6 Correct 55 ms 59128 KB Output is correct
7 Correct 55 ms 59000 KB Output is correct
8 Runtime error 125 ms 117880 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Correct 55 ms 59000 KB Output is correct
10 Correct 59 ms 59000 KB Output is correct
11 Correct 54 ms 59000 KB Output is correct
12 Correct 56 ms 59128 KB Output is correct
13 Correct 61 ms 59128 KB Output is correct
14 Runtime error 137 ms 117936 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Correct 59 ms 59156 KB Output is correct
16 Correct 62 ms 59000 KB Output is correct
17 Correct 66 ms 59000 KB Output is correct
18 Correct 65 ms 59084 KB Output is correct
19 Correct 62 ms 59000 KB Output is correct
20 Correct 57 ms 59000 KB Output is correct
21 Correct 57 ms 59128 KB Output is correct
22 Correct 58 ms 59128 KB Output is correct
23 Correct 67 ms 59128 KB Output is correct
24 Runtime error 132 ms 117984 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Correct 117 ms 60920 KB Output is correct
2 Correct 110 ms 61764 KB Output is correct
3 Correct 117 ms 60860 KB Output is correct
4 Correct 120 ms 61808 KB Output is correct
5 Correct 105 ms 60920 KB Output is correct
6 Correct 94 ms 61140 KB Output is correct
7 Correct 132 ms 61176 KB Output is correct
8 Correct 130 ms 61176 KB Output is correct
9 Runtime error 199 ms 122976 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 411 ms 131576 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Correct 165 ms 62936 KB Output is correct
12 Correct 316 ms 63868 KB Output is correct
13 Correct 226 ms 63100 KB Output is correct
14 Correct 196 ms 62636 KB Output is correct
15 Correct 185 ms 63864 KB Output is correct
16 Correct 298 ms 64348 KB Output is correct
17 Correct 227 ms 63736 KB Output is correct
18 Correct 307 ms 63708 KB Output is correct
19 Runtime error 307 ms 129912 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Runtime error 394 ms 134876 KB Execution killed with signal 11 (could be triggered by violating memory limits)
21 Correct 281 ms 66040 KB Output is correct
22 Correct 259 ms 65016 KB Output is correct
23 Correct 213 ms 65912 KB Output is correct
24 Correct 235 ms 65784 KB Output is correct
25 Correct 255 ms 65244 KB Output is correct
26 Correct 221 ms 64888 KB Output is correct
27 Correct 264 ms 65784 KB Output is correct
28 Correct 383 ms 65784 KB Output is correct
29 Runtime error 294 ms 133112 KB Execution killed with signal 11 (could be triggered by violating memory limits)
30 Runtime error 429 ms 136156 KB Execution killed with signal 11 (could be triggered by violating memory limits)
31 Correct 248 ms 67192 KB Output is correct
32 Correct 383 ms 65796 KB Output is correct
33 Correct 304 ms 65912 KB Output is correct
34 Correct 457 ms 66168 KB Output is correct
35 Correct 276 ms 66300 KB Output is correct
36 Correct 284 ms 67044 KB Output is correct
37 Correct 301 ms 67320 KB Output is correct
38 Correct 378 ms 67064 KB Output is correct
39 Correct 480 ms 67008 KB Output is correct
40 Runtime error 354 ms 137464 KB Execution killed with signal 11 (could be triggered by violating memory limits)
41 Runtime error 485 ms 140748 KB Execution killed with signal 11 (could be triggered by violating memory limits)