답안 #345798

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
345798 2021-01-08T05:19:37 Z daniel920712 악어의 지하 도시 (IOI11_crocodile) C++14
46 / 100
225 ms 9108 KB
#include "crocodile.h"
#include "assert.h"
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <map>
using namespace std;
vector < pair < long long , long long > > Next[100005];
map < long long , long long > how[100005];
bool is[100005];
bool vis[100005];
long long F(long long fa,long long here)
{
    long long t,ok=0;
    vector < long long > tt;
    if(is[here]) return 0;
    if(how[here].find(fa)!=how[here].end()) return how[here][fa];
    if(vis[here]) return -1;
    vis[here]=1;

    for(auto i:Next[here])
    {
        if(i.first!=fa)
        {
            t=F(here,i.first);
            if(t!=-1) tt.push_back(t+i.second);
        }
        else ok=1;
    }
    sort(tt.begin(),tt.end());
    if(tt.size()>=2) how[here][fa]=tt[1];
    else how[here][fa]=-1;
    vis[here]=0;
    //printf("%lld %lld %lld\n",here,fa,how[here][fa]);
    return how[here][fa];
}
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]));
    }
    for(i=0;i<K;i++) is[P[i]]=1;
    return (int) F(-1,0);
}

Compilation message

crocodile.cpp: In function 'long long int F(long long int, long long int)':
crocodile.cpp:15:17: warning: variable 'ok' set but not used [-Wunused-but-set-variable]
   15 |     long long t,ok=0;
      |                 ^~
crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:41:15: warning: unused variable 'a' [-Wunused-variable]
   41 |     long long a,b,c;
      |               ^
crocodile.cpp:41:17: warning: unused variable 'b' [-Wunused-variable]
   41 |     long long a,b,c;
      |                 ^
crocodile.cpp:41:19: warning: unused variable 'c' [-Wunused-variable]
   41 |     long long a,b,c;
      |                   ^
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 7404 KB Output is correct
2 Correct 5 ms 7404 KB Output is correct
3 Correct 5 ms 7404 KB Output is correct
4 Correct 6 ms 7532 KB Output is correct
5 Correct 6 ms 7404 KB Output is correct
6 Correct 5 ms 7404 KB Output is correct
7 Correct 6 ms 7532 KB Output is correct
8 Correct 5 ms 7532 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 7404 KB Output is correct
2 Correct 5 ms 7404 KB Output is correct
3 Correct 5 ms 7404 KB Output is correct
4 Correct 6 ms 7532 KB Output is correct
5 Correct 6 ms 7404 KB Output is correct
6 Correct 5 ms 7404 KB Output is correct
7 Correct 6 ms 7532 KB Output is correct
8 Correct 5 ms 7532 KB Output is correct
9 Correct 31 ms 8044 KB Output is correct
10 Correct 5 ms 7404 KB Output is correct
11 Correct 13 ms 7788 KB Output is correct
12 Incorrect 225 ms 9108 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 7404 KB Output is correct
2 Correct 5 ms 7404 KB Output is correct
3 Correct 5 ms 7404 KB Output is correct
4 Correct 6 ms 7532 KB Output is correct
5 Correct 6 ms 7404 KB Output is correct
6 Correct 5 ms 7404 KB Output is correct
7 Correct 6 ms 7532 KB Output is correct
8 Correct 5 ms 7532 KB Output is correct
9 Correct 31 ms 8044 KB Output is correct
10 Correct 5 ms 7404 KB Output is correct
11 Correct 13 ms 7788 KB Output is correct
12 Incorrect 225 ms 9108 KB Output isn't correct
13 Halted 0 ms 0 KB -