답안 #935916

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
935916 2024-02-29T18:35:54 Z EJIC_B_KEDAX 식물 비교 (IOI20_plants) C++17
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
 
using ll = long long;
 
using namespace std;
 
const int N = 5050;
vector<int> g[N];
int used[N], tmp1[N], tmp2[N];
int clc[N][N];

void dfs(int s, int d) {
	clc[d][s] = 1;
	used[i] = 1;
	for (int i : g[s]) {
		if (!used[i]) {
			dfs(i, d);
		}
	}
}
 
void init(int k, vector<int> r) {
    int n = r.size();
    int ok = 0, last, lev = n, iter = 0;
    for (int i = 0; i < n; i++) {
    	tmp1[i] = -1;
    	tmp2[i] = -1;
    }
    while (ok < n) {
        last = -k;
        for (int i = n - 1; i > n - k; i--) {
            if (!r[i]) {
                last = i - n;
                break;
            }
        }
        vector<int> nw = r;
        for (int i = 0; i < n; i++) {
            if (!r[i]) {
                if (i - last >= k) {
                	if (tmp1[i] != -1) {
                		g[tmp1[i]].push_back(i);
                	}
                	if (tmp2[i] != -1) {
                		g[tmp2[i]].push_back(i);
                	}
                    ok++;
                    for (int j = i - 1; j > i - k; j--) {
                        if (j >= 0) {
                            nw[j]--;
                            tmp1[j] = i;
                        } else {
                            nw[j + n]--;
                            tmp1[j + n] = i;
                        }
                    }
                    for (int j = i + 1; j < i + k; j++) {
                        if (j < n) {
                            tmp2[j] = i;
                        } else {
                            tmp2[j - n] = i;
                        }
                    }
                    nw[i] = INT32_MAX / 2;
                }
                last = i;
            }
        }
        swap(nw, r);
        iter++;
        // assert(iter < n + 10);
    }
    for (int i = 0; i < n; i++) {
    	for (int j = 0; j < n; j++) {
    		used[j] = 0;
    	}
    	dfs(i, i);
    }
}
 
int compare_plants(int x, int y) {
    if (clc[y][x]) {
        return -1;
    }
    return clc[x][y];
}

Compilation message

plants.cpp: In function 'void dfs(int, int)':
plants.cpp:14:7: error: 'i' was not declared in this scope
   14 |  used[i] = 1;
      |       ^
plants.cpp: In function 'void init(int, std::vector<int>)':
plants.cpp:24:23: warning: unused variable 'lev' [-Wunused-variable]
   24 |     int ok = 0, last, lev = n, iter = 0;
      |                       ^~~