답안 #246219

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
246219 2020-07-08T11:33:22 Z uacoder123 악어의 지하 도시 (IOI11_crocodile) C++14
100 / 100
1187 ms 86152 KB
#include <stdio.h>
#include <stdlib.h>
#include <bits/stdc++.h>
#include "crocodile.h"
using namespace std;
#define F first
#define S second
#define FOR(i,a,b) for (auto i = (a); i <= (b); ++i)
#define NFOR(i,a,b) for(auto i = (a); i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define mp(i,a) make_pair(i,a)
#define pb(a) push_back(a)
#define bit(x,b) (x&(1LL<<b))
 
typedef long long int lli;
typedef pair <lli,lli> ii;
typedef pair <lli,ii> iii;
typedef vector <lli> vi;
vector<ii> al[150001];
ii dis[150001];
set<pair<ii,lli>> s;
void dij()
{
  while(s.size()!=0)
  {
    pair<ii,lli> v=(*s.begin());
    s.erase(s.begin());
    dis[v.S]=v.F;
    for(lli i=0;i<al[v.S].size();++i)
    {
      if(dis[al[v.S][i].F].F>al[v.S][i].S+v.F.F)
      {
        s.erase(mp(dis[al[v.S][i].F],al[v.S][i].F));
        if(al[v.S][i].S+v.F.F<dis[al[v.S][i].F].S)
          dis[al[v.S][i].F]=mp(dis[al[v.S][i].F].S,al[v.S][i].S+v.F.F);
        else
          dis[al[v.S][i].F].F=al[v.S][i].S+v.F.F;
        s.insert(mp(dis[al[v.S][i].F],al[v.S][i].F));
      }
    }
  }
}
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
  lli n=N,m=M,k=K;
  for(lli i=0;i<m;++i)
  {
    lli f=R[i][0],se=R[i][1],w=L[i];
    al[f].pb(mp(se,w));
    al[se].pb(mp(f,w));
  }
  for(lli i=0;i<=n;++i)
    dis[i]=mp(1000000000000000000,1000000000000000000);
  for(lli i=0;i<k;++i)
  {
    s.insert(mp(mp(0,0),P[i]));
    dis[P[i]]=mp(0,0);
  }
  dij();
  return(dis[0].F);
}

Compilation message

crocodile.cpp: In function 'void dij()':
crocodile.cpp:30:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(lli i=0;i<al[v.S].size();++i)
                 ~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 3840 KB Output is correct
2 Correct 6 ms 3840 KB Output is correct
3 Correct 8 ms 3840 KB Output is correct
4 Correct 7 ms 3968 KB Output is correct
5 Correct 8 ms 3968 KB Output is correct
6 Correct 7 ms 3968 KB Output is correct
7 Correct 9 ms 3968 KB Output is correct
8 Correct 10 ms 3968 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 3840 KB Output is correct
2 Correct 6 ms 3840 KB Output is correct
3 Correct 8 ms 3840 KB Output is correct
4 Correct 7 ms 3968 KB Output is correct
5 Correct 8 ms 3968 KB Output is correct
6 Correct 7 ms 3968 KB Output is correct
7 Correct 9 ms 3968 KB Output is correct
8 Correct 10 ms 3968 KB Output is correct
9 Correct 11 ms 4224 KB Output is correct
10 Correct 7 ms 3968 KB Output is correct
11 Correct 8 ms 4096 KB Output is correct
12 Correct 11 ms 4608 KB Output is correct
13 Correct 13 ms 4608 KB Output is correct
14 Correct 7 ms 3968 KB Output is correct
15 Correct 9 ms 3968 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 3840 KB Output is correct
2 Correct 6 ms 3840 KB Output is correct
3 Correct 8 ms 3840 KB Output is correct
4 Correct 7 ms 3968 KB Output is correct
5 Correct 8 ms 3968 KB Output is correct
6 Correct 7 ms 3968 KB Output is correct
7 Correct 9 ms 3968 KB Output is correct
8 Correct 10 ms 3968 KB Output is correct
9 Correct 11 ms 4224 KB Output is correct
10 Correct 7 ms 3968 KB Output is correct
11 Correct 8 ms 4096 KB Output is correct
12 Correct 11 ms 4608 KB Output is correct
13 Correct 13 ms 4608 KB Output is correct
14 Correct 7 ms 3968 KB Output is correct
15 Correct 9 ms 3968 KB Output is correct
16 Correct 724 ms 81764 KB Output is correct
17 Correct 113 ms 18936 KB Output is correct
18 Correct 237 ms 21368 KB Output is correct
19 Correct 1187 ms 86152 KB Output is correct
20 Correct 373 ms 68704 KB Output is correct
21 Correct 62 ms 11128 KB Output is correct
22 Correct 406 ms 65248 KB Output is correct