QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#112287#6561. Fail FastITMO_pengzoo#Compile Error//C++202.5kb2023-06-11 03:04:082023-06-11 03:04:12

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-11 03:04:12]
  • 评测
  • [2023-06-11 03:04:08]
  • 提交

answer

//  Nikita Golikov, 2023

#include <bits/stdc++.h>

using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

#ifdef GOLIKOV
  #include "/Users/golikovnik/contests/debug.h"
#else
  #define debug(...) ;
#endif

template <class A, class B>
bool smin(A& x, B&& y) {
  if (y < x) {
    x = y;
    return true;
  }
  return false;
}

template <class A, class B>
bool smax(A& x, B&& y) {
  if (x < y) {
    x = y;
    return true;
  }
  return false;
}

int main() {
#ifdef GOLIKOV
  assert(freopen("in", "rt", stdin));
  auto _clock_start = chrono::high_resolution_clock::now();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  using ld = long double;
  int n; cin >> n;
  vector<int> p(n + 1);
  vector<ld> w(n + 1);
  vector<int> par(n + 1, -1);
  for (int i = 0; i < n; ++i) {
    int c;
    ld pr;
    int d;
    cin >> c >> pr >> d;
    p[i] = c;
    w[i] = 1 - pr;
    par[i] = d - 1;
    if (par[i] < 0) {
      par[i] = n;
    }
  }
  par[n] = -1;
  w[n] = 0.5;
  p[n] = 0.5;
  n++;
  for (int i = 0; i < n; ++i) {
    swap(p[i], w[i]);
  }
  auto ip = p;
  auto iw = w;
  int root = -1;
  for (int i = 0; i < n; ++i) if (par[i] < 0) root = i;
  assert(root >= 0);

  set<pair<ld, int>> st;
  for (int i = 0; i < n; ++i) if (i != root) {
    st.emplace(p[i] / w[i], i);
  }
  vector<deque<int>> order(n);
  for (int i = 0; i < n; ++i) order[i] = {i};

  vector<int> dsu(n);
  iota(dsu.begin(), dsu.end(), 0);
  auto find = [&](auto&& self, int v) -> int {
    return dsu[v] == v ? v : dsu[v] = self(self, dsu[v]); 
  };

  while (!st.empty()) {
    int v = st.begin()->second;
    st.erase(st.begin());

    assert(dsu[v] == v);
    int u = find(find, par[v]);

    if (order[v].size() < order[u].size()) {
      order[u].insert(order[u].end(), order[v].begin(), order[v].end());
    } else {
      order[v].insert(order[v].begin(), order[u].begin(), order[u].end());
      order[v].swap(order[u]);
    }

    if (u != root) {
      st.erase({p[u] / w[u], u});
      w[u] += w[v];
      p[u] += p[v];
      st.emplace(p[u] / w[u], u);
    }
  
    dsu[v] = u;
  }

  assert(dsu[root] == root);
  order[root].erase(order[root].begin());
  for (int v : order[root]) {
    cout << v + 1 << '\n';
  }

#ifdef GOLIKOV
  cerr << "Executed in " << chrono::duration_cast<chrono::milliseconds>(
      chrono::high_resolution_clock::now()
          - _clock_start).count() << "ms." << endl;
#endif
  return 0;
}

Details

answer.code: In function ‘int main()’:
answer.code:65:9: error: no matching function for call to ‘swap(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&, __gnu_cxx::__alloc_traits<std::allocator<long double>, long double>::value_type&)’
   65 |     swap(p[i], w[i]);
      |     ~~~~^~~~~~~~~~~~
In file included from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:3:
/usr/include/c++/11/sstream:1184:5: note: candidate: ‘template<class _CharT, class _Traits, class _Allocator> void std::__cxx11::swap(std::__cxx11::basic_stringbuf<_CharT, _Traits, _Alloc>&, std::__cxx11::basic_stringbuf<_CharT, _Traits, _Alloc>&)’
 1184 |     swap(basic_stringbuf<_CharT, _Traits, _Allocator>& __x,
      |     ^~~~
/usr/include/c++/11/sstream:1184:5: note:   template argument deduction/substitution failed:
answer.code:65:9: note:   mismatched types ‘std::__cxx11::basic_stringbuf<_CharT, _Traits, _Alloc>’ and ‘__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type’ {aka ‘int’}
   65 |     swap(p[i], w[i]);
      |     ~~~~^~~~~~~~~~~~
In file included from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:3:
/usr/include/c++/11/sstream:1192:5: note: candidate: ‘template<class _CharT, class _Traits, class _Allocator> void std::__cxx11::swap(std::__cxx11::basic_istringstream<_CharT, _Traits, _Allocator>&, std::__cxx11::basic_istringstream<_CharT, _Traits, _Allocator>&)’
 1192 |     swap(basic_istringstream<_CharT, _Traits, _Allocator>& __x,
      |     ^~~~
/usr/include/c++/11/sstream:1192:5: note:   template argument deduction/substitution failed:
answer.code:65:9: note:   mismatched types ‘std::__cxx11::basic_istringstream<_CharT, _Traits, _Allocator>’ and ‘__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type’ {aka ‘int’}
   65 |     swap(p[i], w[i]);
      |     ~~~~^~~~~~~~~~~~
In file included from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:3:
/usr/include/c++/11/sstream:1199:5: note: candidate: ‘template<class _CharT, class _Traits, class _Allocator> void std::__cxx11::swap(std::__cxx11::basic_ostringstream<_CharT, _Traits, _Allocator>&, std::__cxx11::basic_ostringstream<_CharT, _Traits, _Allocator>&)’
 1199 |     swap(basic_ostringstream<_CharT, _Traits, _Allocator>& __x,
      |     ^~~~
/usr/include/c++/11/sstream:1199:5: note:   template argument deduction/substitution failed:
answer.code:65:9: note:   mismatched types ‘std::__cxx11::basic_ostringstream<_CharT, _Traits, _Allocator>’ and ‘__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type’ {aka ‘int’}
   65 |     swap(p[i], w[i]);
      |     ~~~~^~~~~~~~~~~~
In file included from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:3:
/usr/include/c++/11/sstream:1206:5: note: candidate: ‘template<class _CharT, class _Traits, class _Allocator> void std::__cxx11::swap(std::__cxx11::basic_stringstream<_CharT, _Traits, _Allocator>&, std::__cxx11::basic_stringstream<_CharT, _Traits, _Allocator>&)’
 1206 |     swap(basic_stringstream<_CharT, _Traits, _Allocator>& __x,
      |     ^~~~
/usr/include/c++/11/sstream:1206:5: note:   template argument deduction/substitution failed:
answer.code:65:9: note:   mismatched types ‘std::__cxx11::basic_stringstream<_CharT, _Traits, _Allocator>’ and ‘__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type’ {aka ‘int’}
   65 |     swap(p[i], w[i]);
      |     ~~~~^~~~~~~~~~~~
In file included from /usr/include/c++/11/regex:63,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:110,
                 from answer.code:3:
/usr/include/c++/11/bits/regex.h:850:5: note: candidate: ‘template<class _Ch_type, class _Rx_traits> void std::__cxx11::swap(std::__cxx11::basic_regex<_Ch_type, _Rx_traits>&, std::__cxx11::basic_regex<_Ch_type, _Rx_traits>&)’
  850 |     swap(basic_regex<_Ch_type, _Rx_traits>& __lhs,
      |     ^~~~
/usr/include/c++/11/bits/regex.h:850:5: note:   template argument deduction/substitution failed:
answer.code:65:9: note:   mismatched types ‘std::__cxx11::basic_regex<_Ch_type, _Rx_traits>’ and ‘__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type’ {aka ‘int’}
   65 |     swap(p[i], w[i]);
      |     ~~~~^~~~~~~~~~~~
In file included from /usr/include/c++/11/regex:63,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:110,
                 from answer.code:3:
/usr/include/c++/11/bits/regex.h:2143:5: note: candidate: ‘template<class _Bi_...