제출 #1357438

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

vector<int> adj[101];
vector<int> vect;
bool vis[101];


void dfs(int x, int p) {
  vis[x]=1;
    vect.push_back(x);
    for (int y : adj[x]) {
      if(vis[y])continue;
        dfs(y, x);
        vect.push_back(x);
    }
}

std::vector<std::vector<int>> create_map(int N, int M, std::vector<int> A, std::vector<int> B) {
  for(int i=0;i<=N;i++)vis[i]=0;
    if(M + M == N * (N - 1)) {
      int h=240;
      vector<vector<int>> v(h, vector<int> (h));
      srand(time(0));
      for(int i=0;i<h;i++){
          for(int j=0;j<h;j++){
              v[i][j] = rand()%N+1;
          }
      }
      return v;
  }
    for (int i = 0; i < 42; i++) {
      adj[i].clear();
    }
    vect.clear();
    for (int i = 0; i < M; i++) {
      adj[A[i]].push_back(B[i]);
      adj[B[i]].push_back(A[i]);
    }
    dfs(1, 0);
    int sz = vect.size();
    std::vector<std::vector<int>> ans(sz, std::vector<int>(sz, 1));
    for (int i = 0; i < sz; i++) {
        for (int j = 0; j < sz; j++) {
            ans[i][j] = ((i + j >= ans.size()) ? ans.back() : ans[i + j]);
        }
    }
  return ans;
}

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

worldmap.cpp: In function 'std::vector<std::vector<int> > create_map(int, int, std::vector<int>, std::vector<int>)':
worldmap.cpp:46:48: error: cannot convert '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} to '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} in assignment
   46 |             ans[i][j] = ((i + j >= ans.size()) ? ans.back() : ans[i + j]);
      |                         ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
      |                                                |
      |                                                __gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type {aka std::vector<int>}