답안 #388913

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
388913 2021-04-13T09:50:50 Z Killer2501 악어의 지하 도시 (IOI11_crocodile) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define task "asd"
#define pll pair<ll, ll>
#define pii pair<pll, ll>
#define fi first
#define se second

using namespace std;
const ll mod = 1e17+7;
const ll N = 1e6+5;
const int base = 313;
const long double Exp = 1e-8;
ll n, m, t, k, T, ans, tong, c[N];
ll a[N], b[N], d[N];
vector<pll> adj[N];
vector<pll> kq;
string s;

void sol()
{
    cin >> n >> m >> k;
    for(int i = 1; i <= m; i ++)
    {
        ll x, y, z;
        cin >> x >> y >> z;
        adj[x].pb({z, y});
        adj[y].pb({z, x});
    }
    priority_queue< pll, vector<pll>, greater<pll> > pq;
    for(int i = 0; i < n; i ++)d[i]= mod;
    for(int i = 1; i <= k; i ++)
    {
        ll x;
        cin >> x;
        d[x] = 0;
        a[x] = 1;
        pq.push({0, x});
    }
    while(!pq.empty())
    {
        pll u = pq.top();
        pq.pop();
        if(a[u.se] == 0)
        {
            a[u.se] = 1;
            continue;
        }
        if(u.se == 0)
        {
            cout << u.fi;
            return;
        }
        for(pll v : adj[u.se])
        {
            pq.push({v.fi+u.fi, v.se});
        }
    }
}
ll travel_plan(int n, int m, int r[][2], int l[], int k, int p[])
{
    for(int i = 0; i < m; i ++)
    {
        ll x, y, z;
        x = r[i][1];
        y = r[i][0];
        z = l[i];
        adj[x].pb({z, y});
        adj[y].pb({z, x});
    }
    priority_queue< pll, vector<pll>, greater<pll> > pq;
    for(int i = 0; i < n; i ++)d[i]= mod;
    for(int i = 0; i < k; i ++)
    {
        ll x = p[i];
        d[x] = 0;
        a[x] = 1;
        pq.push({0, x});
    }
    while(!pq.empty())
    {
        pll u = pq.top();
        pq.pop();
        if(a[u.se] == 0)
        {
            a[u.se] = 1;
            continue;
        }
        if(u.se == 0)
        {
            return u.fi;
        }
        for(pll v : adj[u.se])
        {
            pq.push({v.fi+u.fi, v.se});
        }
    }
}
int main()
{
    if(fopen(task".INP", "r"))
    {
       freopen(task".INP", "r", stdin);
       freopen(task".OUT", "w", stdout);
    }
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int ntest = 1;
    //cin >> ntest;
    while(ntest -- > 0)
    sol();
}
/*
4
2 5
10 10
2 5
3 3
4 5
5 2 4 9
1
8 8
5 3 1 6 10 100 9 15

https://codeforces.com/contest/791/problem/E

*/

Compilation message

crocodile.cpp: In function 'long long int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:72:54: warning: control reaches end of non-void function [-Wreturn-type]
   72 |     priority_queue< pll, vector<pll>, greater<pll> > pq;
      |                                                      ^~
crocodile.cpp: In function 'int main()':
crocodile.cpp:104:15: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
  104 |        freopen(task".INP", "r", stdin);
      |        ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
crocodile.cpp:105:15: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
  105 |        freopen(task".OUT", "w", stdout);
      |        ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/tmp/cc2hSson.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccpQHHOK.o:crocodile.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status