Submission #58250

# Submission time Handle Problem Language Result Execution time Memory
58250 2018-07-17T09:02:16 Z evpipis 007 (CEOI14_007) C++14
30 / 100
862 ms 16508 KB
#include <bits/stdc++.h>
using namespace std;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> ii;
 
const int len = 2e5+5;
int dis[len], tim[len];
int n, m, s1, s2, t1, t2;
queue<int> myq;
vector<int> adj[len];
 
bool check(int x){
    for (int i = 1; i <= n; i++)
        dis[i] = -1;
 
    if (0 < tim[s2]+x)
        dis[s2] = 0, myq.push(s2);
    while (!myq.empty()){
        int u = myq.front();
        myq.pop();
 
        for (int j = 0; j < adj[u].size(); j++){
            int v = adj[u][j];
            if (dis[v] == -1 && dis[u]+1 < tim[v]+x)
                dis[v] = dis[u]+1, myq.push(v);
        }
    }
 
    return (dis[t1] == -1 && dis[t2] == -1);
}
 
int bs(){
    int l = 0, r = n, ans = -1;
    while (l <= r){
        int mid = (l+r)/2;
        if (check(mid))
            l = mid+1, ans = mid;
        else
            r = mid-1;
    }
 
    return ans;
}
 
int main(){
    scanf("%d %d %d %d %d %d", &n, &m, &s1, &s2, &t1, &t2);
    for (int i = 0; i < m; i++){
        int a, b;
        scanf("%d %d", &a, &b);
        adj[a].pb(b);
        adj[b].pb(a);
    }
 
    for (int i = 1; i <= n; i++)
        tim[i] = -1;
 
    tim[s1] = 0, myq.push(s1);
    while (!myq.empty()){
        int u = myq.front();
        myq.pop();
 
        for (int j = 0; j < adj[u].size(); j++){
            int v = adj[u][j];
            if (tim[v] == -1)
                tim[v] = tim[u]+1, myq.push(v);
        }
    }
 
    printf("%d\n", bs() - 1);
    return 0;
}

Compilation message

007.cpp: In function 'bool check(int)':
007.cpp:27:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int j = 0; j < adj[u].size(); j++){
                         ~~^~~~~~~~~~~~~~~
007.cpp: In function 'int main()':
007.cpp:67:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int j = 0; j < adj[u].size(); j++){
                         ~~^~~~~~~~~~~~~~~
007.cpp:51:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d %d %d %d %d", &n, &m, &s1, &s2, &t1, &t2);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
007.cpp:54:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &a, &b);
         ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Partially correct 8 ms 4984 KB Partially correct
2 Partially correct 7 ms 5224 KB Partially correct
3 Partially correct 9 ms 5224 KB Partially correct
4 Correct 8 ms 5224 KB Output is correct
5 Correct 7 ms 5224 KB Output is correct
6 Partially correct 7 ms 5224 KB Partially correct
7 Partially correct 7 ms 5236 KB Partially correct
8 Correct 7 ms 5252 KB Output is correct
9 Partially correct 7 ms 5300 KB Partially correct
10 Partially correct 6 ms 5300 KB Partially correct
11 Partially correct 6 ms 5300 KB Partially correct
12 Correct 6 ms 5300 KB Output is correct
13 Partially correct 6 ms 5312 KB Partially correct
14 Correct 6 ms 5328 KB Output is correct
15 Partially correct 8 ms 5328 KB Partially correct
16 Correct 7 ms 5328 KB Output is correct
17 Correct 7 ms 5328 KB Output is correct
18 Correct 8 ms 5328 KB Output is correct
19 Partially correct 8 ms 5328 KB Partially correct
20 Partially correct 8 ms 5328 KB Partially correct
21 Partially correct 8 ms 5328 KB Partially correct
22 Partially correct 7 ms 5328 KB Partially correct
23 Partially correct 6 ms 5328 KB Partially correct
24 Correct 7 ms 5328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 73 ms 6860 KB Partially correct
2 Correct 99 ms 7804 KB Output is correct
3 Partially correct 71 ms 7804 KB Partially correct
4 Correct 67 ms 7804 KB Output is correct
5 Partially correct 79 ms 7804 KB Partially correct
6 Partially correct 95 ms 7804 KB Partially correct
7 Partially correct 96 ms 7804 KB Partially correct
8 Partially correct 76 ms 7804 KB Partially correct
9 Correct 152 ms 7804 KB Output is correct
10 Partially correct 286 ms 11900 KB Partially correct
11 Correct 174 ms 11900 KB Output is correct
12 Partially correct 350 ms 11900 KB Partially correct
13 Correct 167 ms 11900 KB Output is correct
14 Partially correct 147 ms 11900 KB Partially correct
15 Partially correct 208 ms 11900 KB Partially correct
16 Partially correct 242 ms 11900 KB Partially correct
17 Partially correct 287 ms 11900 KB Partially correct
18 Correct 308 ms 11900 KB Output is correct
19 Partially correct 262 ms 11900 KB Partially correct
20 Correct 496 ms 13696 KB Output is correct
21 Correct 292 ms 13696 KB Output is correct
22 Partially correct 301 ms 13696 KB Partially correct
23 Partially correct 376 ms 13696 KB Partially correct
24 Partially correct 243 ms 13696 KB Partially correct
25 Correct 384 ms 13696 KB Output is correct
26 Partially correct 298 ms 13696 KB Partially correct
27 Partially correct 463 ms 13696 KB Partially correct
28 Partially correct 605 ms 13696 KB Partially correct
29 Partially correct 467 ms 13696 KB Partially correct
30 Correct 574 ms 14332 KB Output is correct
31 Correct 610 ms 14332 KB Output is correct
32 Partially correct 442 ms 14332 KB Partially correct
33 Partially correct 385 ms 14332 KB Partially correct
34 Correct 705 ms 14332 KB Output is correct
35 Correct 472 ms 14332 KB Output is correct
36 Correct 498 ms 14332 KB Output is correct
37 Partially correct 653 ms 14332 KB Partially correct
38 Partially correct 571 ms 14332 KB Partially correct
39 Partially correct 805 ms 14332 KB Partially correct
40 Correct 499 ms 14332 KB Output is correct
41 Partially correct 862 ms 16508 KB Partially correct