제출 #347892

#제출 시각아이디문제언어결과실행 시간메모리
347892evn슈퍼트리 잇기 (IOI20_supertrees)C++14
컴파일 에러
0 ms0 KiB
#include "supertrees.h" #include <bits/stdc++.h> using namespace std; #define f first #define s second #define pb push_back #define mp make_pair #define sz(a) a.size() typedef long long ll; typedef pair<int, int> pii; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; int N; int dsu[1005]; int sz[1005]; int find(int u){ if(dsu[u] == u)return u; return dsu[u] = find(dsu[u]); } void merge(int u, int v){ u = find(u); v = find(v); if(u == v)return; if(sz[u] < sz[v])swap(u,v); dsu[v] = u; sz[u] += sz[v]; } int construct(vector<vector<int>> p){ N = p.size(); bool c0 = false; bool c1 = false; bool c2 = false; bool c3 = false; for(int i = 0; i < N; i++){ for(int j = 0;j < N; j++){ if(p[i][j] == 0)c0 = true; if(p[i][j] == 1)c1 = true; if(p[i][j] == 2)c2 = true; if(p[i][j] == 3)c3 = true; } } if(c1 && !c2 && !c3){ //tree case vector<vector<int>> b; for(int i = 0; i < N;i ++){ int c1 = 2*i + 1; int c2 = 2*i + 2; int p = (i-1)/2; if(i == 0)p =-1; vector<int> curr; for(int j = 0;j < N; j++){ if(j == p || j == c1 || j== c2){ curr.pb(1); } else{ curr.pb(0); } } b.pb(curr); } build(b); return 1; } if(c1 ^ c2){ //subtask 2/3 //do dsu for(int i = 0;i < N; i++){ dsu[i] = i; sz[i] = 1; } for(int i = 0; i < N;i ++){ for(int j = 0;j < N; j++){ if(p[i][j] == 0){ if(find(i) == find(j)){ //not possible return 0; } } else{ merge(i, j); } } } if(c1){ //subtask 2 //make a line int edges[N][N]; int prev[N]; memset(prev, -1, sizeof(prev)); memset(edges, 0, sizeof(edges)); for(int i = 0; i < N;i ++){ int cmp = find(i); if(prev[cmp] != -1){ edges[prev[cmp]][i] = 1; edges[i][prev[cmp]] = 1; } prev[cmp] = i; } build(edges); } else{ } return 1; } return 0; }

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

supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:102:10: error: could not convert '(int (*)[N])(& edges)' from 'int (*)[N]' to 'std::vector<std::vector<int> >'
  102 |    build(edges);
      |          ^~~~~
      |          |
      |          int (*)[N]