답안 #171590

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
171590 2019-12-29T10:22:57 Z MvC 007 (CEOI14_007) C++11
0 / 100
313 ms 24404 KB
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=2e5+50;
const int mod=1e9+7;
using namespace std;
int n,m,s[2],a[2],d[2][nmax],x,y,mn,i,j;
vector<int>g[nmax];
stack<pair<int,int> >q;
pair<int,int>p;
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n>>m;
	cin>>s[0]>>s[1]>>a[0]>>a[1];
	while(m--)
	{
		cin>>x>>y;
		g[x].pb(y);
		g[y].pb(x);
	}
	for(j=0;j<2;j++)
	{
		for(i=1;i<=n;i++)d[j][i]=inf;
		q.push(mkp(s[j],0));
		d[j][s[j]]=0;
		while(!q.empty())
		{
			p=q.top();
			q.pop();
			for(i=0;i<(int)g[p.fr].size();i++)
			{
				x=g[p.fr][i];
				if(d[j][x]!=inf)continue;
				d[j][x]=p.sc+1;
				q.push(mkp(x,d[j][x]));
			}
		}
	}
	mn=inf;
	for(i=0;i<2;i++)
	{
		x=a[i];
		mn=min(mn,d[1][x]-d[0][x]);
	}
	if(mn<-1)mn=-1;
	cout<<mn<<endl;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 4984 KB Output isn't correct
2 Incorrect 7 ms 5112 KB Output isn't correct
3 Incorrect 7 ms 5112 KB Output isn't correct
4 Incorrect 7 ms 5116 KB Output isn't correct
5 Partially correct 7 ms 5116 KB Partially correct
6 Correct 7 ms 5072 KB Output is correct
7 Incorrect 7 ms 4984 KB Output isn't correct
8 Incorrect 7 ms 4984 KB Output isn't correct
9 Incorrect 7 ms 4984 KB Output isn't correct
10 Incorrect 7 ms 4984 KB Output isn't correct
11 Correct 7 ms 4984 KB Output is correct
12 Correct 8 ms 5112 KB Output is correct
13 Incorrect 6 ms 5112 KB Output isn't correct
14 Incorrect 7 ms 5060 KB Output isn't correct
15 Incorrect 7 ms 4984 KB Output isn't correct
16 Incorrect 7 ms 5112 KB Output isn't correct
17 Incorrect 7 ms 5072 KB Output isn't correct
18 Incorrect 7 ms 5112 KB Output isn't correct
19 Incorrect 7 ms 5112 KB Output isn't correct
20 Incorrect 7 ms 5112 KB Output isn't correct
21 Incorrect 7 ms 5112 KB Output isn't correct
22 Incorrect 7 ms 5112 KB Output isn't correct
23 Incorrect 6 ms 5112 KB Output isn't correct
24 Partially correct 7 ms 5112 KB Partially correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 26 ms 7188 KB Output isn't correct
2 Incorrect 42 ms 8044 KB Output isn't correct
3 Incorrect 32 ms 7288 KB Output isn't correct
4 Incorrect 39 ms 8184 KB Output isn't correct
5 Incorrect 30 ms 7160 KB Output isn't correct
6 Incorrect 31 ms 7288 KB Output isn't correct
7 Incorrect 33 ms 7544 KB Output isn't correct
8 Incorrect 34 ms 7644 KB Output isn't correct
9 Incorrect 50 ms 8568 KB Output isn't correct
10 Incorrect 178 ms 17324 KB Output isn't correct
11 Incorrect 60 ms 9720 KB Output isn't correct
12 Incorrect 81 ms 11000 KB Output isn't correct
13 Incorrect 67 ms 10360 KB Output isn't correct
14 Correct 58 ms 9324 KB Output is correct
15 Incorrect 86 ms 11000 KB Output isn't correct
16 Incorrect 85 ms 11356 KB Output isn't correct
17 Incorrect 66 ms 10588 KB Output isn't correct
18 Incorrect 76 ms 10616 KB Output isn't correct
19 Incorrect 120 ms 13372 KB Output isn't correct
20 Incorrect 216 ms 19652 KB Output isn't correct
21 Incorrect 104 ms 13304 KB Output isn't correct
22 Incorrect 97 ms 12280 KB Output isn't correct
23 Incorrect 118 ms 13176 KB Output isn't correct
24 Incorrect 115 ms 13208 KB Output isn't correct
25 Incorrect 103 ms 12664 KB Output isn't correct
26 Incorrect 99 ms 12280 KB Output isn't correct
27 Incorrect 122 ms 13304 KB Output isn't correct
28 Incorrect 124 ms 13300 KB Output isn't correct
29 Incorrect 160 ms 15736 KB Output isn't correct
30 Incorrect 233 ms 20452 KB Output isn't correct
31 Incorrect 135 ms 14556 KB Output isn't correct
32 Incorrect 129 ms 13300 KB Output isn't correct
33 Incorrect 123 ms 13680 KB Output isn't correct
34 Incorrect 130 ms 13944 KB Output isn't correct
35 Incorrect 122 ms 13560 KB Output isn't correct
36 Incorrect 129 ms 13964 KB Output isn't correct
37 Incorrect 164 ms 15212 KB Output isn't correct
38 Incorrect 160 ms 14924 KB Output isn't correct
39 Incorrect 153 ms 15160 KB Output isn't correct
40 Incorrect 227 ms 19256 KB Output isn't correct
41 Incorrect 313 ms 24404 KB Output isn't correct