답안 #976269

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
976269 2024-05-06T11:24:31 Z saayan007 공장들 (JOI14_factories) C++17
컴파일 오류
0 ms 0 KB
#include "factories.h"
#include "bits/stdc++.h"
using namespace std;

#warning using32bitint
#define int long long
typedef long long ll;
typedef pair<int, int> pi;
#define rep(i, a, b) for(int (i) = (a); i <= (b); ++i)
#define repd(i, a, b) for(int (i) = (a); i >= (b); --i)

#define em emplace
#define eb emplace_back

#define fr first
#define sc second
#define mp make_pair

const char nl = '\n';

#warning checkconstanst as per subtask
const int mxN = 5e5L + 10;

vector<pair<int, ll>> adj[mxN];
bool spec[mxN];
ll dist[mxN];
queue<int> q;
int n;

void Init(int N, int A[], int B[], int D[]) {
    n = N;
    rep(i, 0, N - 2) {
        adj[A[i]].eb(B[i], D[i]);
        adj[B[i]].eb(A[i], D[i]);
    }
    rep(i, 0, N - 1) {
        spec[i] = 0;
        dist[i] = -1;
    }
}

long long Query(int S, int X[], int T, int Y[]) {
    rep(i, 0, S - 1) spec[X[i]] = 1;
    /* for(int x : X) spec[x] = 1; */

    /* for(int y : Y) { */
    rep(i, 0, T - 1) {
        dist[Y[i]] = 0;
        q.push(Y[i]);
    }
    
    while(!q.empty()) {
        int a = q.front();
        q.pop();
        for(auto tmp : adj[a]) {
            int b = tmp.fr; ll w = tmp.sc;
            if(dist[b] != -1) continue;
            dist[b] = dist[a] + w;
            q.push(b);
        }
    }

    ll res = mxN;
    rep(i, 0, S - 1) {
        if(dist[X[i]] != -1 && dist[X[i]] < res) res = dist[X[i]];
    }

    rep(i, 0, n - 1) dist[i] = -1;
    rep(i, 0, S - 1) spec[X[i]] = 0;

    return res;
}

Compilation message

factories.cpp:5:2: warning: #warning using32bitint [-Wcpp]
    5 | #warning using32bitint
      |  ^~~~~~~
factories.cpp:21:2: warning: #warning checkconstanst as per subtask [-Wcpp]
   21 | #warning checkconstanst as per subtask
      |  ^~~~~~~
factories.cpp: In function 'void Init(long long int, long long int*, long long int*, long long int*)':
factories.cpp:9:30: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    9 | #define rep(i, a, b) for(int (i) = (a); i <= (b); ++i)
      |                              ^
factories.cpp:32:5: note: in expansion of macro 'rep'
   32 |     rep(i, 0, N - 2) {
      |     ^~~
factories.cpp:9:30: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    9 | #define rep(i, a, b) for(int (i) = (a); i <= (b); ++i)
      |                              ^
factories.cpp:36:5: note: in expansion of macro 'rep'
   36 |     rep(i, 0, N - 1) {
      |     ^~~
factories.cpp: In function 'long long int Query(long long int, long long int*, long long int, long long int*)':
factories.cpp:9:30: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    9 | #define rep(i, a, b) for(int (i) = (a); i <= (b); ++i)
      |                              ^
factories.cpp:43:5: note: in expansion of macro 'rep'
   43 |     rep(i, 0, S - 1) spec[X[i]] = 1;
      |     ^~~
factories.cpp:9:30: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    9 | #define rep(i, a, b) for(int (i) = (a); i <= (b); ++i)
      |                              ^
factories.cpp:47:5: note: in expansion of macro 'rep'
   47 |     rep(i, 0, T - 1) {
      |     ^~~
factories.cpp:9:30: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    9 | #define rep(i, a, b) for(int (i) = (a); i <= (b); ++i)
      |                              ^
factories.cpp:64:5: note: in expansion of macro 'rep'
   64 |     rep(i, 0, S - 1) {
      |     ^~~
factories.cpp:9:30: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    9 | #define rep(i, a, b) for(int (i) = (a); i <= (b); ++i)
      |                              ^
factories.cpp:68:5: note: in expansion of macro 'rep'
   68 |     rep(i, 0, n - 1) dist[i] = -1;
      |     ^~~
factories.cpp:9:30: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
    9 | #define rep(i, a, b) for(int (i) = (a); i <= (b); ++i)
      |                              ^
factories.cpp:69:5: note: in expansion of macro 'rep'
   69 |     rep(i, 0, S - 1) spec[X[i]] = 0;
      |     ^~~
/usr/bin/ld: /tmp/cczZQVfX.o: in function `main':
grader.cpp:(.text.startup+0x37d): undefined reference to `Init(int, int*, int*, int*)'
/usr/bin/ld: grader.cpp:(.text.startup+0x412): undefined reference to `Query(int, int*, int, int*)'
collect2: error: ld returned 1 exit status