# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
171596 |
2019-12-29T10:32:46 Z |
MvC |
007 (CEOI14_007) |
C++11 |
|
310 ms |
17656 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];
queue<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.front();
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;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
4984 KB |
Output is correct |
2 |
Correct |
7 ms |
5112 KB |
Output is correct |
3 |
Correct |
7 ms |
5112 KB |
Output is correct |
4 |
Incorrect |
7 ms |
4984 KB |
Output isn't correct |
5 |
Incorrect |
6 ms |
4984 KB |
Output isn't correct |
6 |
Correct |
6 ms |
4984 KB |
Output is correct |
7 |
Correct |
7 ms |
4984 KB |
Output is correct |
8 |
Incorrect |
7 ms |
4984 KB |
Output isn't correct |
9 |
Correct |
6 ms |
4984 KB |
Output is correct |
10 |
Correct |
6 ms |
4984 KB |
Output is correct |
11 |
Correct |
7 ms |
4984 KB |
Output is correct |
12 |
Incorrect |
7 ms |
5112 KB |
Output isn't correct |
13 |
Correct |
7 ms |
5112 KB |
Output is correct |
14 |
Incorrect |
7 ms |
4984 KB |
Output isn't correct |
15 |
Correct |
7 ms |
5116 KB |
Output is correct |
16 |
Incorrect |
7 ms |
5112 KB |
Output isn't correct |
17 |
Incorrect |
7 ms |
5116 KB |
Output isn't correct |
18 |
Incorrect |
7 ms |
5112 KB |
Output isn't correct |
19 |
Correct |
7 ms |
5112 KB |
Output is correct |
20 |
Correct |
7 ms |
5112 KB |
Output is correct |
21 |
Correct |
7 ms |
5112 KB |
Output is correct |
22 |
Correct |
7 ms |
5092 KB |
Output is correct |
23 |
Correct |
7 ms |
5112 KB |
Output is correct |
24 |
Incorrect |
7 ms |
5112 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
31 ms |
7160 KB |
Output is correct |
2 |
Incorrect |
40 ms |
7988 KB |
Output isn't correct |
3 |
Correct |
31 ms |
7288 KB |
Output is correct |
4 |
Incorrect |
40 ms |
8184 KB |
Output isn't correct |
5 |
Correct |
36 ms |
7160 KB |
Output is correct |
6 |
Correct |
31 ms |
7288 KB |
Output is correct |
7 |
Correct |
34 ms |
7544 KB |
Output is correct |
8 |
Correct |
36 ms |
7544 KB |
Output is correct |
9 |
Incorrect |
48 ms |
8312 KB |
Output isn't correct |
10 |
Correct |
170 ms |
13136 KB |
Output is correct |
11 |
Incorrect |
64 ms |
9720 KB |
Output isn't correct |
12 |
Correct |
85 ms |
10872 KB |
Output is correct |
13 |
Incorrect |
73 ms |
10004 KB |
Output isn't correct |
14 |
Correct |
54 ms |
9336 KB |
Output is correct |
15 |
Correct |
87 ms |
10988 KB |
Output is correct |
16 |
Correct |
94 ms |
11352 KB |
Output is correct |
17 |
Correct |
114 ms |
10588 KB |
Output is correct |
18 |
Incorrect |
95 ms |
10672 KB |
Output isn't correct |
19 |
Correct |
114 ms |
12188 KB |
Output is correct |
20 |
Incorrect |
271 ms |
15092 KB |
Output isn't correct |
21 |
Incorrect |
121 ms |
12920 KB |
Output isn't correct |
22 |
Correct |
107 ms |
12096 KB |
Output is correct |
23 |
Correct |
133 ms |
12784 KB |
Output is correct |
24 |
Correct |
122 ms |
12668 KB |
Output is correct |
25 |
Incorrect |
124 ms |
12412 KB |
Output isn't correct |
26 |
Correct |
123 ms |
12132 KB |
Output is correct |
27 |
Correct |
129 ms |
12840 KB |
Output is correct |
28 |
Correct |
135 ms |
12792 KB |
Output is correct |
29 |
Correct |
158 ms |
13484 KB |
Output is correct |
30 |
Incorrect |
250 ms |
15760 KB |
Output isn't correct |
31 |
Incorrect |
148 ms |
13836 KB |
Output isn't correct |
32 |
Correct |
125 ms |
12772 KB |
Output is correct |
33 |
Correct |
111 ms |
13056 KB |
Output is correct |
34 |
Incorrect |
136 ms |
13352 KB |
Output isn't correct |
35 |
Incorrect |
126 ms |
13040 KB |
Output isn't correct |
36 |
Incorrect |
136 ms |
13320 KB |
Output isn't correct |
37 |
Correct |
154 ms |
14200 KB |
Output is correct |
38 |
Correct |
154 ms |
13912 KB |
Output is correct |
39 |
Correct |
163 ms |
13940 KB |
Output is correct |
40 |
Incorrect |
212 ms |
15472 KB |
Output isn't correct |
41 |
Correct |
310 ms |
17656 KB |
Output is correct |