# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
171593 |
2019-12-29T10:30:27 Z |
MvC |
007 (CEOI14_007) |
C++11 |
|
304 ms |
18044 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;
if(mn!=-1 && d[0][a[0]]==d[0][a[1]] && d[1][a[0]]==d[1][a[1]])mn--;
cout<<mn<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
7 ms |
5112 KB |
Output isn't correct |
2 |
Incorrect |
7 ms |
5112 KB |
Output isn't correct |
3 |
Incorrect |
6 ms |
5112 KB |
Output isn't correct |
4 |
Incorrect |
6 ms |
4984 KB |
Output isn't correct |
5 |
Partially correct |
7 ms |
5112 KB |
Partially correct |
6 |
Correct |
7 ms |
5112 KB |
Output is correct |
7 |
Incorrect |
6 ms |
5112 KB |
Output isn't correct |
8 |
Incorrect |
6 ms |
5112 KB |
Output isn't correct |
9 |
Incorrect |
6 ms |
5112 KB |
Output isn't correct |
10 |
Incorrect |
7 ms |
5112 KB |
Output isn't correct |
11 |
Correct |
7 ms |
5112 KB |
Output is correct |
12 |
Correct |
6 ms |
5112 KB |
Output is correct |
13 |
Incorrect |
7 ms |
5240 KB |
Output isn't correct |
14 |
Incorrect |
6 ms |
4984 KB |
Output isn't correct |
15 |
Incorrect |
6 ms |
4984 KB |
Output isn't correct |
16 |
Incorrect |
7 ms |
5112 KB |
Output isn't correct |
17 |
Incorrect |
6 ms |
5112 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 |
5084 KB |
Output isn't correct |
21 |
Incorrect |
8 ms |
5112 KB |
Output isn't correct |
22 |
Incorrect |
7 ms |
5112 KB |
Output isn't correct |
23 |
Incorrect |
7 ms |
5112 KB |
Output isn't correct |
24 |
Partially correct |
7 ms |
5112 KB |
Partially correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
26 ms |
7160 KB |
Output isn't correct |
2 |
Incorrect |
36 ms |
8056 KB |
Output isn't correct |
3 |
Incorrect |
29 ms |
7256 KB |
Output isn't correct |
4 |
Incorrect |
37 ms |
8232 KB |
Output isn't correct |
5 |
Incorrect |
28 ms |
7012 KB |
Output isn't correct |
6 |
Incorrect |
30 ms |
7300 KB |
Output isn't correct |
7 |
Incorrect |
32 ms |
7544 KB |
Output isn't correct |
8 |
Incorrect |
33 ms |
7544 KB |
Output isn't correct |
9 |
Incorrect |
49 ms |
8288 KB |
Output isn't correct |
10 |
Incorrect |
171 ms |
12960 KB |
Output isn't correct |
11 |
Incorrect |
58 ms |
9336 KB |
Output isn't correct |
12 |
Incorrect |
81 ms |
10232 KB |
Output isn't correct |
13 |
Incorrect |
71 ms |
9720 KB |
Output isn't correct |
14 |
Correct |
51 ms |
9080 KB |
Output is correct |
15 |
Incorrect |
79 ms |
10440 KB |
Output isn't correct |
16 |
Incorrect |
84 ms |
10784 KB |
Output isn't correct |
17 |
Incorrect |
110 ms |
10108 KB |
Output isn't correct |
18 |
Incorrect |
77 ms |
10232 KB |
Output isn't correct |
19 |
Incorrect |
125 ms |
11696 KB |
Output isn't correct |
20 |
Incorrect |
217 ms |
14704 KB |
Output isn't correct |
21 |
Incorrect |
118 ms |
12064 KB |
Output isn't correct |
22 |
Incorrect |
111 ms |
11368 KB |
Output isn't correct |
23 |
Incorrect |
112 ms |
12024 KB |
Output isn't correct |
24 |
Incorrect |
115 ms |
11908 KB |
Output isn't correct |
25 |
Incorrect |
115 ms |
11612 KB |
Output isn't correct |
26 |
Incorrect |
96 ms |
11336 KB |
Output isn't correct |
27 |
Incorrect |
117 ms |
12044 KB |
Output isn't correct |
28 |
Incorrect |
133 ms |
12024 KB |
Output isn't correct |
29 |
Incorrect |
164 ms |
13148 KB |
Output isn't correct |
30 |
Incorrect |
248 ms |
15416 KB |
Output isn't correct |
31 |
Incorrect |
145 ms |
13048 KB |
Output isn't correct |
32 |
Incorrect |
181 ms |
11972 KB |
Output isn't correct |
33 |
Incorrect |
153 ms |
12408 KB |
Output isn't correct |
34 |
Incorrect |
139 ms |
12536 KB |
Output isn't correct |
35 |
Incorrect |
181 ms |
12292 KB |
Output isn't correct |
36 |
Incorrect |
164 ms |
12672 KB |
Output isn't correct |
37 |
Incorrect |
143 ms |
13556 KB |
Output isn't correct |
38 |
Incorrect |
145 ms |
13436 KB |
Output isn't correct |
39 |
Incorrect |
140 ms |
13560 KB |
Output isn't correct |
40 |
Incorrect |
225 ms |
15716 KB |
Output isn't correct |
41 |
Incorrect |
304 ms |
18044 KB |
Output isn't correct |