답안 #1088060

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1088060 2024-09-13T19:14:02 Z vincentbucourt1 열대 식물원 (Tropical Garden) (IOI11_garden) C++14
컴파일 오류
0 ms 0 KB
    #include "garden.h"
    #include "gardenlib.h"
    #include <bits/stdc++.h>
    using namespace std;
    #define f first
    #define s second
	#define int long long
     
    const int INF = 1e9;
    const int MAXN = 2 * 150001;
     
    int V, E, dest;
    vector<int> graph[MAXN];
    int lenMove[MAXN];
     
    int adj[MAXN];
    vector<int> revAdj[MAXN];
     
    int jump[MAXN][33];
     
    int distGo (int node, int len) {
    	for (int i = 0; i < 33; i++) {
    		if (len & (1 << i)) {
    			node = jump[node][i];
    		}
    	}
    	return node;
    }
     
    void count_routes(int N, int M, int P, int R[][2], int Q, int G[]) {
     
    	V = N, E = M, dest = P;
    	for (int i = 0; i < Q; i++) {
    		lenMove[i] = G[i];
    	}
     
    	for (int i = 0; i < E; i++) {
    		graph[R[i][0]].push_back(R[i][1]);
    		graph[R[i][1]].push_back(R[i][0]);
    	}
     
    	for (int i = 0; i < V; i++) {
    		if (graph[graph[i][0]][0] == i) {
    			adj[i] = graph[i][0] + V;
    			revAdj[adj[i]].push_back(i);
    		}
    		else {
    			adj[i] = graph[i][0];
    			revAdj[adj[i]].push_back(i);
    		}
    	}
     
    	for (int i = 0; i < V; i++) {
    		if (graph[i].size() > 1 && graph[graph[i][1]][0] == i) {
    			adj[i + V] = graph[i][1] + V;
    			revAdj[adj[i + V]].push_back(i + V);
    		}
    		else if (graph[i].size() == 1 && graph[graph[i][0]][0] == i) {
    			adj[i + V] = graph[i][0] + V;
    			revAdj[adj[i + V]].push_back(i + V);
    		}
    		else {
    			adj[i + V] = graph[i][1];
    			revAdj[adj[i + V]].push_back(i + V);
    		}
    	}
     
    	for (int i = 0; i < 2*V; i++) {
    		jump[i][0] = adj[i];
    	}
     
    	for (int i = 1; i < 33; i++) {
    		for (int node = 0; node < 2*N; node++) {
    			jump[node][i] = jump[jump[node][i-1]][i-1];
    		}
    	}
     
    	int endOn;
    	int ans;
    	for (int q = 0; q < Q; q++) {
    		ans = 0;
    		for (int node = 0; node < V; node++) {
    			endOn = distGo(node, lenMove[q]);
    			if (endOn == dest || endOn == dest+V) {
    				ans++;
    			}
    		}
    		answer(ans);
    	}
    }

Compilation message

/usr/bin/ld: /tmp/ccH0kYCJ.o: in function `main':
grader.cpp:(.text.startup+0x3f): undefined reference to `count_routes(int, int, int, int (*) [2], int, int*)'
collect2: error: ld returned 1 exit status