제출 #667237

#제출 시각아이디문제언어결과실행 시간메모리
667237kirakaminski968Sirni (COCI17_sirni)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> using namespace __gnu_pbds; using namespace std; const int N = 1e5+100; struct DSU { vi e; void init(int N) { e = vi(N,-1); } int get(int x) { return e[x] < 0 ? x : e[x] = get(e[x]); } bool sameSet(int a, int b) { return get(a) == get(b); } int size(int x) { return -e[get(x)]; } bool unite(int x, int y) { // union by size x = get(x), y = get(y); if (x == y) return 0; if (e[x] > e[y]) swap(x,y); e[x] += e[y]; e[y] = x; return 1; } }; int n; vector<int> v(N), a; vector<bool> is(N); vector<array<int, 3>> edges[N]; void solve(){ cin >> n; a.resize(n); for(int i = 0; i < n; ++i) cin >> a[i]; DSU d(n); sort(a.begin(),a.end()); a.resize(unique(a.begin(),a.end()) - a.begin()); n = a.size(); for(int i = 0; i < n - 1; ++i){ for(int j = a[i]; j <= a.back(); j += a[i]){ int k = lower_bound(a.begin() + i + 1, a.end(), j) - a.begin(); if(k >= n || a[k] - j > a[i]) continue; edges[a[k] - j].pb({a[k] - j, k, i}); } } ll ans = 0; for(int i = 0; i < N; ++i) for(auto v: edges[i]){ if(d.find(v[1]) != d.find(v[2])){ d.merge(v[1], v[2]); ans += v[0]; } } cout << ans; } int main(){ cin.tie(0); ios::sync_with_stdio(0); solve(); return 0; }

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

sirni.cpp:2:17: error: '__gnu_pbds' is not a namespace-name
    2 | using namespace __gnu_pbds;
      |                 ^~~~~~~~~~
sirni.cpp:6:3: error: 'vi' does not name a type
    6 |   vi e; void init(int N) { e = vi(N,-1); }
      |   ^~
sirni.cpp: In member function 'void DSU::init(int)':
sirni.cpp:6:28: error: 'e' was not declared in this scope
    6 |   vi e; void init(int N) { e = vi(N,-1); }
      |                            ^
sirni.cpp:6:32: error: 'vi' was not declared in this scope
    6 |   vi e; void init(int N) { e = vi(N,-1); }
      |                                ^~
sirni.cpp: In member function 'int DSU::get(int)':
sirni.cpp:7:27: error: 'e' was not declared in this scope
    7 |   int get(int x) { return e[x] < 0 ? x : e[x] = get(e[x]); }
      |                           ^
sirni.cpp: In member function 'int DSU::size(int)':
sirni.cpp:9:29: error: 'e' was not declared in this scope
    9 |   int size(int x) { return -e[get(x)]; }
      |                             ^
sirni.cpp: In member function 'bool DSU::unite(int, int)':
sirni.cpp:12:9: error: 'e' was not declared in this scope
   12 |     if (e[x] > e[y]) swap(x,y);
      |         ^
sirni.cpp:13:5: error: 'e' was not declared in this scope
   13 |     e[x] += e[y]; e[y] = x; return 1;
      |     ^
sirni.cpp: In function 'void solve()':
sirni.cpp:24:10: error: no matching function for call to 'DSU::DSU(int&)'
   24 |   DSU d(n);
      |          ^
sirni.cpp:5:8: note: candidate: 'constexpr DSU::DSU()'
    5 | struct DSU {
      |        ^~~
sirni.cpp:5:8: note:   candidate expects 0 arguments, 1 provided
sirni.cpp:5:8: note: candidate: 'constexpr DSU::DSU(const DSU&)'
sirni.cpp:5:8: note:   no known conversion for argument 1 from 'int' to 'const DSU&'
sirni.cpp:5:8: note: candidate: 'constexpr DSU::DSU(DSU&&)'
sirni.cpp:5:8: note:   no known conversion for argument 1 from 'int' to 'DSU&&'
sirni.cpp:32:23: error: 'class std::vector<std::array<int, 3> >' has no member named 'pb'
   32 |       edges[a[k] - j].pb({a[k] - j, k, i});
      |                       ^~
sirni.cpp:35:3: error: 'll' was not declared in this scope
   35 |   ll ans = 0;
      |   ^~
sirni.cpp:38:12: error: 'struct DSU' has no member named 'find'
   38 |       if(d.find(v[1]) != d.find(v[2])){
      |            ^~~~
sirni.cpp:38:28: error: 'struct DSU' has no member named 'find'
   38 |       if(d.find(v[1]) != d.find(v[2])){
      |                            ^~~~
sirni.cpp:39:11: error: 'struct DSU' has no member named 'merge'
   39 |         d.merge(v[1], v[2]);
      |           ^~~~~
sirni.cpp:40:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   40 |         ans += v[0];
      |         ^~~
      |         abs
sirni.cpp:43:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   43 |   cout << ans;
      |           ^~~
      |           abs