제출 #1252557

#제출 시각아이디문제언어결과실행 시간메모리
1252557bzzzzzzzzzz세계 지도 (IOI25_worldmap)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#include "worldmap.h"
using namespace std;
using ll = long long;

const int SIZE = 41;

vector<int> o;
vector<int> used(SIZE, 0);
vector<vector<int>> g(SIZE);

void dfs(int v) {
    o.push_back(v);
    used[v] = 1;
    for (auto i : g[v]) {
        if (used[i] == 0) {
            dfs(i);
        }
    }
    o.push_back(v);
}

std::vector<std::vector<int>> create_map(int N, int M, std::vector<int> A, std::vector<int> B) {
    int p = 0;
    for (int i = 0; i < M; i++) {
        if (A[i] == 1) {
            p++;
        }
        if (B[i] == 1) {
            p++;
        }
    }
    if (M == N * (N - 1) / 2) {
        vector<vector<int>> ans(240, vector<int> (240, 1));
        int c = 0;
        int h = 0;
        for (int i = 1; i <= N; i++) {
            for (int j = 1; j <= N; j++) {
                ans[c][h] = i;
                ans[c][h + 1] = j;
                c++;
                if (c == 240) {
                    c = 0;
                    h += 2;
                }
            }
        }
        return ans;
    } else if (M == N - 1 && p != N - 1) {
        for (int i = 0; i < M; i++) {
            g[A[i]].push_back(B[i]);
            g[B[i]].push_back(A[i]);
        }
        int n = (int)o.size();
        vector<vector<int>> ans(n, vector<int> (n, 1));
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                ans[i][j] = o[i];
            }
        }
        return ans;
    } else {
        int c = 0;
        int h = 0;
        for (int i = 0; i < M; i++) {
            ans[c][h] = A[i];
            ans[c][h + 1] = B[j];
            c++;
            if (c == 240) {
                c = 0;
                h += 2;
            }
        }
        return ans;
    }
}

컴파일 시 표준 에러 (stderr) 메시지

worldmap.cpp: In function 'std::vector<std::vector<int> > create_map(int, int, std::vector<int>, std::vector<int>)':
worldmap.cpp:66:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   66 |             ans[c][h] = A[i];
      |             ^~~
      |             abs
worldmap.cpp:67:31: error: 'j' was not declared in this scope
   67 |             ans[c][h + 1] = B[j];
      |                               ^
worldmap.cpp:74:16: error: 'ans' was not declared in this scope; did you mean 'abs'?
   74 |         return ans;
      |                ^~~
      |                abs