답안 #391834

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
391834 2021-04-20T03:27:40 Z Kevin_Zhang_TW 007 (CEOI14_007) C++17
0 / 100
297 ms 17664 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb emplace_back
#define AI(i) begin(i), end(i)
template<class T> bool chmin(T &a, T b) { return b < a && (a = b, true); }
template<class T> bool chmax(T &a, T b) { return a < b && (a = b, true); }
#ifdef KEV
#define DE(args...) kout("[ " + string(#args) + " ] = ", args)
void kout() { cerr << endl; }
template<class T, class ...U> void kout(T a, U ...b) { cerr << a << ' ', kout(b...); }
template<class T> void debug(T l, T r) { while (l != r) cerr << *l << " \n"[next(l)==r], ++l; }
#else
#define DE(...) 0
#define debug(...) 0
#endif

const int MAX_N = 200010, inf = 1e9;

int n, m, s, d, A, B;
vector<int> edge[MAX_N];

int diss[MAX_N], disd[MAX_N], disa[MAX_N], disb[MAX_N];

void get_dis(int s, int *dis) {
	fill(dis, dis + n + 1, inf);

	queue<int> q;
	q.emplace(s); dis[s] = 0;
	while (q.size()) {
		int x = q.front(); q.pop();
		for (int u : edge[x])
			if (chmin(dis[u], dis[x] + 1))
				q.emplace(u);
	}
}
bool valid(int rest) {
	auto test = [&](int x) {
		int art = diss[x] + rest;
		int ga = art + disa[x], gb = art + disb[x];
		if (max(disa[x], disb[x]) > 1) return false;

		int da = disd[A], db = disd[B];

		if (min(disa[x], disb[x]) == 1) {
			if (art <= min(da, db)) return true;
			return false;
		}

		if (ga <= da && gb <= db) return true;

		return false;
	};

	for (int i = 1;i <= n;++i)
		if (test(i)) return true;
	return false;

}
	
int32_t main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n >> m >> s >> d >> A >> B;
	for (int a, b, i = 0;i < m;++i) {
		cin >> a >> b;
		DE(a, b);
		edge[a].pb(b), edge[b].pb(a);
	}
	get_dis(s, diss), get_dis(d, disd);
	get_dis(A, disa), get_dis(B, disb);

	return 1;
	if (!valid(0)) return puts("-1"), 0;

	int l = 0, r = n, mid;
	while (l < r) {
		mid = l + r >> 1;
		if (valid(mid+1))
			l = mid + 1;
		else
			r = mid;
	}
	cout << l << '\n';
}

Compilation message

007.cpp: In function 'int32_t main()':
007.cpp:14:17: warning: statement has no effect [-Wunused-value]
   14 | #define DE(...) 0
      |                 ^
007.cpp:66:3: note: in expansion of macro 'DE'
   66 |   DE(a, b);
      |   ^~
007.cpp:77:11: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   77 |   mid = l + r >> 1;
      |         ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 4940 KB Execution failed because the return code was nonzero
2 Runtime error 3 ms 4940 KB Execution failed because the return code was nonzero
3 Runtime error 3 ms 4940 KB Execution failed because the return code was nonzero
4 Runtime error 3 ms 4940 KB Execution failed because the return code was nonzero
5 Runtime error 3 ms 4940 KB Execution failed because the return code was nonzero
6 Runtime error 3 ms 4940 KB Execution failed because the return code was nonzero
7 Runtime error 4 ms 4940 KB Execution failed because the return code was nonzero
8 Runtime error 3 ms 4940 KB Execution failed because the return code was nonzero
9 Runtime error 3 ms 4940 KB Execution failed because the return code was nonzero
10 Runtime error 4 ms 4940 KB Execution failed because the return code was nonzero
11 Runtime error 4 ms 4940 KB Execution failed because the return code was nonzero
12 Runtime error 4 ms 4940 KB Execution failed because the return code was nonzero
13 Runtime error 4 ms 4940 KB Execution failed because the return code was nonzero
14 Runtime error 3 ms 4940 KB Execution failed because the return code was nonzero
15 Runtime error 3 ms 4940 KB Execution failed because the return code was nonzero
16 Runtime error 4 ms 4940 KB Execution failed because the return code was nonzero
17 Runtime error 4 ms 4940 KB Execution failed because the return code was nonzero
18 Runtime error 4 ms 5068 KB Execution failed because the return code was nonzero
19 Runtime error 3 ms 5068 KB Execution failed because the return code was nonzero
20 Runtime error 4 ms 4940 KB Execution failed because the return code was nonzero
21 Runtime error 4 ms 4940 KB Execution failed because the return code was nonzero
22 Runtime error 4 ms 4940 KB Execution failed because the return code was nonzero
23 Runtime error 4 ms 5068 KB Execution failed because the return code was nonzero
24 Runtime error 4 ms 5068 KB Execution failed because the return code was nonzero
# 결과 실행 시간 메모리 Grader output
1 Runtime error 26 ms 6860 KB Execution failed because the return code was nonzero
2 Runtime error 34 ms 7756 KB Execution failed because the return code was nonzero
3 Runtime error 27 ms 6912 KB Execution failed because the return code was nonzero
4 Runtime error 36 ms 7800 KB Execution failed because the return code was nonzero
5 Runtime error 27 ms 6724 KB Execution failed because the return code was nonzero
6 Runtime error 26 ms 7140 KB Execution failed because the return code was nonzero
7 Runtime error 31 ms 7256 KB Execution failed because the return code was nonzero
8 Runtime error 30 ms 7204 KB Execution failed because the return code was nonzero
9 Runtime error 41 ms 7668 KB Execution failed because the return code was nonzero
10 Runtime error 155 ms 12028 KB Execution failed because the return code was nonzero
11 Runtime error 74 ms 9296 KB Execution failed because the return code was nonzero
12 Runtime error 88 ms 10336 KB Execution failed because the return code was nonzero
13 Runtime error 64 ms 9540 KB Execution failed because the return code was nonzero
14 Runtime error 49 ms 8780 KB Execution failed because the return code was nonzero
15 Runtime error 73 ms 10436 KB Execution failed because the return code was nonzero
16 Runtime error 79 ms 10684 KB Execution failed because the return code was nonzero
17 Runtime error 80 ms 10172 KB Execution failed because the return code was nonzero
18 Runtime error 82 ms 10128 KB Execution failed because the return code was nonzero
19 Runtime error 105 ms 11224 KB Execution failed because the return code was nonzero
20 Runtime error 226 ms 14108 KB Execution failed because the return code was nonzero
21 Runtime error 109 ms 12484 KB Execution failed because the return code was nonzero
22 Runtime error 111 ms 11500 KB Execution failed because the return code was nonzero
23 Runtime error 106 ms 12368 KB Execution failed because the return code was nonzero
24 Runtime error 105 ms 12296 KB Execution failed because the return code was nonzero
25 Runtime error 105 ms 11972 KB Execution failed because the return code was nonzero
26 Runtime error 98 ms 11544 KB Execution failed because the return code was nonzero
27 Runtime error 123 ms 12420 KB Execution failed because the return code was nonzero
28 Runtime error 136 ms 12484 KB Execution failed because the return code was nonzero
29 Runtime error 148 ms 12880 KB Execution failed because the return code was nonzero
30 Runtime error 217 ms 15060 KB Execution failed because the return code was nonzero
31 Runtime error 131 ms 13640 KB Execution failed because the return code was nonzero
32 Runtime error 139 ms 12376 KB Execution failed because the return code was nonzero
33 Runtime error 138 ms 12688 KB Execution failed because the return code was nonzero
34 Runtime error 180 ms 13016 KB Execution failed because the return code was nonzero
35 Runtime error 112 ms 12740 KB Execution failed because the return code was nonzero
36 Runtime error 133 ms 13000 KB Execution failed because the return code was nonzero
37 Runtime error 164 ms 14088 KB Execution failed because the return code was nonzero
38 Runtime error 164 ms 14096 KB Execution failed because the return code was nonzero
39 Runtime error 198 ms 13848 KB Execution failed because the return code was nonzero
40 Runtime error 225 ms 15428 KB Execution failed because the return code was nonzero
41 Runtime error 297 ms 17664 KB Execution failed because the return code was nonzero