제출 #304055

#제출 시각아이디문제언어결과실행 시간메모리
3040552qbingxuan슈퍼트리 잇기 (IOI20_supertrees)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #define safe std::cerr<<__PRETTY_FUNCTION__<<" line "<<__LINE__<<" safe\n" #define debug(...) qqbx(#__VA_ARGS__, __VA_ARGS__) template <typename H, typename ...T> void qqbx(const char*s, const H &h, T ...args) { for(; *s && *s != ','; ++s) if(*s != ' ') std::cerr << *s; std::cerr << " = " << h << (sizeof...(T) ? ", " : "\n"); if constexpr (sizeof...(T)) qqbx(++s, args...); } #define pb emplace_back using namespace std; typedef long long ll; const int N = 2500025; struct Dsu { vector<int> pa; Dsu(int n) : pa(n) { iota(pa.begin(), pa.end(), 0); } int anc(int x) { return x==pa[x] ? x : pa[x]=anc(pa[x]); } bool same(int x, int y) { return anc(x) == anc(y); } bool join(int x, int y) { if((x=anx(x)) == (y=anc(y))) return false; return pa[y] = x, true; } }; int construct(vector<vector<int>> p) { int n = p.size(); vector<vector<int>> res(n, vector<int>(n)); Dsu dsu(n); for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) { if(p[i][j] == 1) { if(dsu.join(i, j)) res[i][j] = res[j][i] = 1; } } vector<vector<int>> g(n); for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) { if(p[i][j] == 2) { int a = dsu.anc(i), b = dsu.anc(j); if(a == b) return 0; g[a].pb(b); } } for(int i = 0; i < n; i++) if(!vis[i]) { if(!g[i].size()) continue; vector<int> tmp; dfs(i, tmp); if(tmp.size() == 2) return 0; int last = tmp.back(); for(int x: tmp) { res[last][x] = res[x][last] = 1; dsu.join(last, x); last = x; } } for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) if(p[i][j] == 0 && dsu.same(i, j)) return 0; build(res); return 1; }

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

supertrees.cpp: In function 'void qqbx(const char*, const H&, T ...)':
supertrees.cpp:7:8: warning: 'if constexpr' only available with '-std=c++17' or '-std=gnu++17'
    7 |     if constexpr (sizeof...(T)) qqbx(++s, args...);
      |        ^~~~~~~~~
supertrees.cpp: In member function 'bool Dsu::join(int, int)':
supertrees.cpp:21:15: error: 'anx' was not declared in this scope; did you mean 'anc'?
   21 |         if((x=anx(x)) == (y=anc(y))) return false;
      |               ^~~
      |               anc
supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:42:36: error: 'vis' was not declared in this scope
   42 |     for(int i = 0; i < n; i++) if(!vis[i]) {
      |                                    ^~~
supertrees.cpp:45:9: error: 'dfs' was not declared in this scope; did you mean 'ffs'?
   45 |         dfs(i, tmp);
      |         ^~~
      |         ffs
supertrees.cpp:55:5: error: 'build' was not declared in this scope
   55 |     build(res);
      |     ^~~~~