제출 #635623

#제출 시각아이디문제언어결과실행 시간메모리
635623nayhzJob Scheduling (CEOI12_jobs)C++17
컴파일 에러
0 ms0 KiB
// CEOI 2012 Dau 1 Job Scheduling #include <bits/stdc++.h> #define pii pair<int, int> #define vi vector<int> #define vpii vector<pair<int, int>> #define fi first #define se second #define pb push_back #define mp make_pair #define all(x) (x).begin(), (x).end() using namespace std; /* >>>>>>>>>>>>>>>>>>>>>>>>>>END OF TEMPLATE HEADER<<<<<<<<<<<<<<<<<<<<<<<< */ void solve () { int n, d, m; cin >> n >> d >> m; vpii a(m); for (int i = 0; i < m; i++) {cin >> a[i].fi; a[i].se = i + 1;} sort(all(a)); vector<vi> ans(n); int l = 1, r = m, mid, day, i, cnt; vector<vi> ret(n); function<pair<bool, vector<vi>> ()> check = [&] () { ret.clear(); ret.resize(n); cnt = 0; for (day = 1; day <= n; day++) { for (i = 0; i < mid; i++) { if (a[cnt].fi > day) break; if (a[cnt].fi + d >= day){ ret[day - 1].pb(a[cnt++].se); } else return mp(false, ret); if (cnt == m) { return mp(true, ret); } } } return mp(false, ret); }; pair<bool, vector<vi>> ret; while (l < r) { mid = l + ((r - l) >> 1); ret = check(); if (ret.fi) { r = mid, ans = ret.se; } else l = mid + 1; } cout << l << '\n'; for (i = 0; i < n; i++) { for (int j = 0; j < (int)ans[i].size(); j++) cout << ans[i][j] << ' '; cout << "0\n"; } } signed main () { solve(); return 0; }

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

jobs.cpp: In function 'void solve()':
jobs.cpp:51:25: error: conflicting declaration 'std::pair<bool, std::vector<std::vector<int> > > ret'
   51 |  pair<bool, vector<vi>> ret;
      |                         ^~~
jobs.cpp:28:13: note: previous declaration as 'std::vector<std::vector<int> > ret'
   28 |  vector<vi> ret(n);
      |             ^~~
jobs.cpp:55:15: error: no match for 'operator=' (operand types are 'std::vector<std::vector<int> >' and 'std::pair<bool, std::vector<std::vector<int> > >')
   55 |   ret = check();
      |               ^
In file included from /usr/include/c++/10/vector:72,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from jobs.cpp:2:
/usr/include/c++/10/bits/vector.tcc:198:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >]'
  198 |     vector<_Tp, _Alloc>::
      |     ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/vector.tcc:199:42: note:   no known conversion for argument 1 from 'std::pair<bool, std::vector<std::vector<int> > >' to 'const std::vector<std::vector<int> >&'
  199 |     operator=(const vector<_Tp, _Alloc>& __x)
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/10/vector:67,
                 from /usr/include/c++/10/functional:62,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from jobs.cpp:2:
/usr/include/c++/10/bits/stl_vector.h:709:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >]'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:709:26: note:   no known conversion for argument 1 from 'std::pair<bool, std::vector<std::vector<int> > >' to 'std::vector<std::vector<int> >&&'
  709 |       operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
      |                 ~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:730:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >]'
  730 |       operator=(initializer_list<value_type> __l)
      |       ^~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:730:46: note:   no known conversion for argument 1 from 'std::pair<bool, std::vector<std::vector<int> > >' to 'std::initializer_list<std::vector<int> >'
  730 |       operator=(initializer_list<value_type> __l)
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
jobs.cpp:8:12: error: 'class std::vector<std::vector<int> >' has no member named 'first'
    8 | #define fi first
      |            ^~~~~
jobs.cpp:56:11: note: in expansion of macro 'fi'
   56 |   if (ret.fi) {
      |           ^~
jobs.cpp:9:12: error: 'class std::vector<std::vector<int> >' has no member named 'second'
    9 | #define se second
      |            ^~~~~~
jobs.cpp:57:23: note: in expansion of macro 'se'
   57 |    r = mid, ans = ret.se;
      |                       ^~