답안 #26958

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
26958 2017-07-07T12:53:07 Z repeating 악어의 지하 도시 (IOI11_crocodile) C++11
100 / 100
1513 ms 174384 KB
#include <bits/stdc++.h>
#include "crocodile.h"
#define F first
#define S second
#define P push
#define pb push_back
#define MEM(dp,i) memset(dp,i,sizeof(dp))
#define W while
#define R return
#define C continue
#define SI size()
#define ll long long
#define ld long double
#define pll pair<ll,ll>
#define pii pair<int,int>
#define SF(x) scanf("%I64d",&x)
#define SF2(x,y) scanf("%I64d%I64d",&x,&y)
#define SF3(x,y,z) scanf("%I64d%I64d%I64d",&x,&y,&z)
#define SF4(x,y,z,o) scanf("%I64d%I64d%I64d%I64d",&x,&y,&z,&o)
#define all(v) v.begin(),v.end()
//#define MAX_N 50000
//#define MAX_M 10000000
using namespace std;
const long long INF = 1e9+5e8;
const int MX=100009;
int n,m,k;
int res[MX];
bool check[MX];
bool vis[MX];
vector<pii> adj[MX];
priority_queue< pii , vector<pii> , greater<pii> > pq;
int solve(){
    W(!pq.empty()){
        int ver=pq.top().S,dis=pq.top().F;
        pq.pop();
        if(vis[ver])C;
        if(check[ver])vis[ver]=1;
        else{
            check[ver]=1;
            C;
        }
        res[ver]=dis;
        for(auto i : adj[ver]){
            pq.P({dis+i.S,i.F});
        }
    }
    R res[0];
}
int travel_plan(int N, int M, int r[][2], int L[], int K, int p[])
{
    n=N,m=M,k=K;
    for(int i=0;i<m;i++){
        adj[r[i][0]].pb({r[i][1],L[i]});
        adj[r[i][1]].pb({r[i][0],L[i]});
    }
    for(int i=0;i<k;i++){
        res[p[i]]=0;
        check[p[i]]=1;
        pq.P({0,p[i]});
    }
    return solve();
}

//static int N, M;
//static int r[MAX_M][2];
//static int L[MAX_M];
//static int K;
//static int p[MAX_N];
//static int solution;
//
//inline
//void my_assert(int e) {if (!e) abort();}
//
//void read_input()
//{
//  int i;
//  my_assert(3==scanf("%d %d %d",&N,&M,&K));
//  for(i=0; i<M; i++)
//    my_assert(3==scanf("%d %d %d",&r[i][0],&r[i][1],&L[i]));
//  for(i=0; i<K; i++)
//    my_assert(1==scanf("%d",&p[i]));
//  my_assert(1==scanf("%d",&solution));
//}
//
//int main()
//{
//  int ans;
//  read_input();
//  ans = travel_plan(N,M,r,L,K,p);
//  if(ans==solution)
//    printf("Correct.\n");
//  else
//    printf("Incorrect. Returned %d, Expected %d.\n",ans,solution);
//
//  return 0;
//}

# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 122332 KB Output is correct
2 Correct 0 ms 122332 KB Output is correct
3 Correct 0 ms 122332 KB Output is correct
4 Correct 3 ms 122464 KB Output is correct
5 Correct 0 ms 122468 KB Output is correct
6 Correct 0 ms 122332 KB Output is correct
7 Correct 0 ms 122464 KB Output is correct
8 Correct 3 ms 122332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 122740 KB Output is correct
2 Correct 0 ms 122332 KB Output is correct
3 Correct 3 ms 122464 KB Output is correct
4 Correct 13 ms 123020 KB Output is correct
5 Correct 9 ms 123100 KB Output is correct
6 Correct 0 ms 122332 KB Output is correct
7 Correct 3 ms 122464 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1383 ms 172024 KB Output is correct
2 Correct 116 ms 127084 KB Output is correct
3 Correct 203 ms 128272 KB Output is correct
4 Correct 1513 ms 174384 KB Output is correct
5 Correct 786 ms 169884 KB Output is correct
6 Correct 53 ms 124708 KB Output is correct
7 Correct 736 ms 141468 KB Output is correct