Submission #16366

#TimeUsernameProblemLanguageResultExecution timeMemory
16366suhgyuho_williamComputer Network (BOI14_network)C++98
0 / 100
143 ms5200 KiB
#include "network.h"
#include <map>
using namespace std;

map<int,int> path;
map<int,int>::iterator it;

void findRoute (int n, int a, int b)
{
    /*
     *  Obviously, this is not a good solution.
     *  Replace it with your own code.
     */

    int dist = ping(a, b);
    int x,y;

    path[dist+1]=b;
    int i;
    for(i=1;i<=n;i++){
        if(i==a || i==b) continue;
        x=ping(a,i);
        if(path.find(x+1)!=path.end()) continue;
        path[x+1]=i;
        it=path.find(x+1);
        it++;
        y=ping(i,it->second);
        if(it->first != x+y+2){
            path.erase(x+1);
        }
    }
    for(it=path.begin(); it!=path.end(); it++){
        travelTo(it->second);
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...