답안 #59883

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
59883 2018-07-23T08:33:12 Z tmwilliamlin168 007 (CEOI14_007) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

inline int in() {
	int result = 0;
	char ch = getchar_unlocked();
	while(true) {
		if(ch >= '0' && ch <= '9')
			break;
		ch = getchar_unlocked();
	}
	result = ch-'0';
	while(true) {
		ch = getchar_unlocked();
		if (ch < '0' || ch > '9')
			break;
		result = result*10 + (ch - '0');
	}
	return result;
}
inline void out(int x) {
	if(!x) {
		putchar_unlocked('0');
		return;
	}
	if(x<0) {
		putchar_unlocked('-')
		x=-x;
	}
	int rev=x, c=0;
	while(!(rev%10)) {
		++c;
		rev/=10;
	}
	rev=0;
	while(x) {
		rev=rev*10+x%10;
		x/=10;
	}
	while(rev) {
		putchar_unlocked(rev%10+'0');
		rev/=10;
	}
	while(c--)
		putchar_unlocked('0');
}

const int mxN=2e5;
int n, m, s, d, a, b, da[mxN], db[mxN], qu[mxN], qh, qt, dp[mxN];
vector<int> adj[mxN];

inline void bfs(int s, int dist[mxN]) {
	qh=qt=0;
	memset(dist, 0x3F, 4*n);
	qu[qt++]=s;
	dist[s]=0;
	while(qh<qt) {
		int u=qu[qh++];
		for(int v : adj[u]) {
			if(dist[v]>n) {
				qu[qt++]=v;
				dist[v]=dist[u]+1;
			}
		}
	}
}

int cdp(int u) {
	if(!dp[u]) {
		dp[u]=da[u];
		for(int v : adj[u])
			if(da[v]==da[u]-1&&da[v]==db[v])
				dp[u]=min(cdp(v), dp[u]);
	}
	return dp[u];
}

int main() {
	n=in(), m=in(), s=in()-1, d=in()-1, a=in(), b=in();
	while(m--) {
		int u=in()-1, v=in()-1;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	bfs(a, da);
	bfs(b, db);
	if(da[s]!=db[s]||da[d]!=db[d])
		out(max(min(da[d]-da[s], db[d]-db[s]), -1));
	else
		out(max(da[d]-da[s]-(cdp(d)<cdp(s)), -1));
}

Compilation message

007.cpp: In function 'void out(int)':
007.cpp:28:3: error: expected ';' before 'x'
   x=-x;
   ^