Submission #65051

# Submission time Handle Problem Language Result Execution time Memory
65051 2018-08-06T13:50:27 Z bazsi700 007 (CEOI14_007) C++14
Compilation error
0 ms 0 KB
    #include <bits/stdc++.h>
     
    using namespace std;
     
    int main()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
        int n,m,s,d,a,b;
        cin >> n >> m >> s >> d >> a >> b;
        vector<vector<int> > graph(n+1,vector<int>());
        for(int i = 0; i < m; i++) {
            int x,y;
            cin >> x >> y;
            graph[x].push_back(y);
            graph[y].push_back(x);
        }
        vector<bool> wass(n+1,false);
        vector<int> dists(n+1,0);
        vector<bool> wasd(n+1,false);
        vector<int> distd(n+1,0);
        vector<bool> wasa(n+1,false);
        vector<int> dista(n+1,0);
        vector<bool> wasb(n+1,false);
        vector<int> distb(n+1,0);
        wass[s] = true;
        queue<int> q;
        q.push(s);
        while(!q.empty()) {
            int v = q.front();
            q.pop();
            for(int u : graph[v]) {
                if(!wass[u]) {
                    wass[u] = true;
                    q.push(u);
                    dists[u] = dists[v]+1;
                }
            }
        }
        wasd[d] = true;
        q.push(d);
        while(!q.empty()) {
            int v = q.front();
            q.pop();
            for(int u : graph[v]) {
                if(!wasd[u]) {
                    wasd[u] = true;
                    q.push(u);
                    distd[u] = distd[v]+1;
                }
            }
        }
        wasa[a] = true;
        q.push(a);
        while(!q.empty()) {
            int v = q.front();
            q.pop();
            for(int u : graph[v]) {
                if(!wasa[u]) {
                    wasa[u] = true;
                    q.push(u);
                    dista[u] = dista[v]+1;
                }
            }
        }
        wasb[b] = true;
        q.push(b);
        while(!q.empty()) {
            int v = q.front();
            q.pop();
            for(int u : graph[v]) {
                if(!wasb[u]) {
                    wasb[u] = true;
                    q.push(u);
                    distb[u] = distb[v]+1;
                }
            }
        }
        if(dists[a] == dists[b] && distd[a] == distd[b]) {
            int mndistd = -1;
            int mndists = -1;
            for(int i = 1; i <= n; i++) {
              //  if(dista[i] == distb[i]) {
                    if(dista[i]+distd[i] == distd[a]) {
                        mndistd = min(mndistd,dista[i]);
                    }
                    if(dista[i]+dists[i] == dists[a]) {
                        mndists = min(mndists,dista[i]);
                    }
              //  }
            }
            if(mxdists > mxdistd) {
                cout << max(min(distd[a]-dists[a],distd[b]-dists[b])-1,-1);
            } else {
                cout << max(min(distd[a]-dists[a],distd[b]-dists[b]),-1);
            }
        } else {
            cout << max(min(distd[a]-dists[a],distd[b]-dists[b]),-1);
        }
        return 0;
    }

Compilation message

007.cpp: In function 'int main()':
007.cpp:92:16: error: 'mxdists' was not declared in this scope
             if(mxdists > mxdistd) {
                ^~~~~~~
007.cpp:92:16: note: suggested alternative: 'mndists'
             if(mxdists > mxdistd) {
                ^~~~~~~
                mndists
007.cpp:92:26: error: 'mxdistd' was not declared in this scope
             if(mxdists > mxdistd) {
                          ^~~~~~~
007.cpp:92:26: note: suggested alternative: 'mndistd'
             if(mxdists > mxdistd) {
                          ^~~~~~~
                          mndistd