답안 #345773

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
345773 2021-01-08T03:49:40 Z daniel920712 악어의 지하 도시 (IOI11_crocodile) C++14
46 / 100
15 ms 11624 KB
#include "crocodile.h"
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <map>
using namespace std;
bool is[100005];
bool vis[5][100005];
vector < pair < long long , long long > > Next[100005];
vector < pair < long long , long long > > Next2[100005];
map < long long , long long > how[100005];
bool have[5][100005]={0};
priority_queue < pair < long long , pair < long long , long long > > , vector < pair < long long , pair < long long , long long > > > , greater < pair < long long , pair < long long , long long > > > > dij;
long long F(long long fa,long long here)
{
    if(vis[0][here]==0) vis[0][here]=1;
    else if(vis[1][here]==0) vis[1][here]=1;
    long long t;
    vector < long long > tt;
    if(is[here]) return 0;
    for(auto i:Next2[here])
    {
        if(!vis[1][i.first]&&i.first!=fa)
        {
            t=F(here,i.first);
            if(t!=-1) tt.push_back(t+i.second);
        }
    }
    sort(tt.begin(),tt.end());
    if(tt.size()>=2) return tt[1];
    else return -1;
}
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
    int i;
    long long a,b,c;
    for(i=0;i<M;i++)
    {
        Next[R[i][0]].push_back(make_pair((long long) R[i][1],(long long) L[i]));
        Next[R[i][1]].push_back(make_pair((long long) R[i][0],(long long) L[i]));
        how[R[i][0]][R[i][1]]=L[i];
        how[R[i][1]][R[i][0]]=L[i];
    }
    dij.push(make_pair(0,make_pair(0,-1)));
    while(!dij.empty())
    {
        a=dij.top().first;
        b=dij.top().second.first;
        c=dij.top().second.second;
        dij.pop();
        if(have[0][b]==0) have[0][b]=1;
        else if(have[1][b]==0) have[1][b]=1;
        else continue;
        if(c!=-1) Next2[c].push_back(make_pair(b,how[b][c]));
        for(auto i:Next[b])
        {
            if(i.first!=c) dij.push(make_pair(i.second+a,make_pair(i.first,b)));
        }
    }
    for(i=0;i<K;i++) is[P[i]]=1;
    return (int) F(-1,0);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 9708 KB Output is correct
2 Correct 6 ms 9708 KB Output is correct
3 Correct 6 ms 9836 KB Output is correct
4 Correct 7 ms 9964 KB Output is correct
5 Correct 7 ms 9964 KB Output is correct
6 Correct 7 ms 9964 KB Output is correct
7 Correct 7 ms 9964 KB Output is correct
8 Correct 7 ms 9964 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 9708 KB Output is correct
2 Correct 6 ms 9708 KB Output is correct
3 Correct 6 ms 9836 KB Output is correct
4 Correct 7 ms 9964 KB Output is correct
5 Correct 7 ms 9964 KB Output is correct
6 Correct 7 ms 9964 KB Output is correct
7 Correct 7 ms 9964 KB Output is correct
8 Correct 7 ms 9964 KB Output is correct
9 Incorrect 15 ms 11624 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 9708 KB Output is correct
2 Correct 6 ms 9708 KB Output is correct
3 Correct 6 ms 9836 KB Output is correct
4 Correct 7 ms 9964 KB Output is correct
5 Correct 7 ms 9964 KB Output is correct
6 Correct 7 ms 9964 KB Output is correct
7 Correct 7 ms 9964 KB Output is correct
8 Correct 7 ms 9964 KB Output is correct
9 Incorrect 15 ms 11624 KB Output isn't correct
10 Halted 0 ms 0 KB -