답안 #897793

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
897793 2024-01-03T17:05:27 Z Trumling 악어의 지하 도시 (IOI11_crocodile) C++14
100 / 100
405 ms 89880 KB
#include "crocodile.h"
#include<bits/stdc++.h>
using namespace std;
    
typedef long long ll;
#define pb push_back
#define F first
#define S second
#define enter cout<<'\n';
#define INF 9999999999999999
#define MOD 1000000007
#define round fixed<<setprecision(2)<<

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
  vector<vector<pair<ll,ll>>>g(N+1);
  for(int i=0;i<M;i++)
  {
    g[R[i][0]].pb({R[i][1],L[i]});
    g[R[i][1]].pb({R[i][0],L[i]});
  }

  priority_queue<pair<ll,ll>>pq;
  vector<pair<ll,ll>>dist(N+1,{INF,INF});
  for(int i=0;i<K;i++)
  {
    dist[P[i]]={0,0};
    pq.push({0,P[i]});
  }

  while(!pq.empty())
  {
    ll curr=pq.top().S;
    ll w=-pq.top().F;
    pq.pop();

    if(dist[curr].S<w)
    continue;

    for(auto x:g[curr])
    {
      if(dist[x.F].F> w + x.S)
      {
        
      if(dist[x.F].F!=dist[x.F].S)
         pq.push({-dist[x.F].F,x.F});
      
        
         swap(dist[x.F].F,dist[x.F].S);
        dist[x.F].F=w + x.S;
       // pq.push({-dist[x.F].F,x.F});
        continue;
      }

      if(dist[x.F].S> w + x.S)
      {
        dist[x.F].S=w + x.S;
        pq.push({-dist[x.F].S,x.F});
      }

    }
  }
  return (int) dist[0].S;
    
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:45:7: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   45 |       if(dist[x.F].F!=dist[x.F].S)
      |       ^~
crocodile.cpp:49:10: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   49 |          swap(dist[x.F].F,dist[x.F].S);
      |          ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4548 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4548 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 2 ms 4700 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4700 KB Output is correct
12 Correct 3 ms 4956 KB Output is correct
13 Correct 3 ms 5212 KB Output is correct
14 Correct 1 ms 4696 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4548 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 2 ms 4700 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4700 KB Output is correct
12 Correct 3 ms 4956 KB Output is correct
13 Correct 3 ms 5212 KB Output is correct
14 Correct 1 ms 4696 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 328 ms 82204 KB Output is correct
17 Correct 55 ms 19284 KB Output is correct
18 Correct 75 ms 21840 KB Output is correct
19 Correct 405 ms 89880 KB Output is correct
20 Correct 234 ms 66384 KB Output is correct
21 Correct 27 ms 11056 KB Output is correct
22 Correct 245 ms 64292 KB Output is correct