제출 #303479

#제출 시각아이디문제언어결과실행 시간메모리
303479Vimmer카니발 티켓 (IOI20_tickets)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#include "tickets.h"
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define N 1005
#define PB push_back
#define sz(x) int(x.size())
#define P 31
#define F first
#define M ll(1e9 + 7)
#define S second
#define all(x) x.begin(), x.end()
#define endl '\n'

//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("no-stack-protector")

using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;

//typedef tree<int, null_type, less_equal <int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

ll mlt(ll a, ll b) {return (a * b) % M;}
ll sm(ll a, ll b) {return (a + b) % M;}

ll calc(vector <vector <int> > &x, ll md)
{
    ll sum = 0;

    for (int i = 0; i < sz(x); i++) sum += abs(md - x[i][0]);

    return sum;
}

ll clc(vector <int> &x, ll md)
{
    ll sum = 0;

    for (int i = 0; i < sz(x); i++) sum += abs(md - x[i]);

    return sum;
}

ll calcer(vector <vector <int> > &x, ll md)
{
    vector <int> xt; xt.clear();

    for (int i = 0; i < sz(x); i++)
        if (x[i][0] <= md) xt.PB(x[i][0]); else xt.PB(x[i].back());

    sort(xt.begin(), xt.end());

    ll l = 0, r = 1e9;

    while (l < r)
    {
        ll mdl = (l + r) / 2;

        ll mdr = mdl + 1;

        if (clc(xt, mdl) > clc(xt, mdr)) l = mdr;
          else r = mdl;
    }

    return clc(xt, l);
}

ll find_maximum(int k, vector<vector<int> > x)
{
	int n = sz(x);

	int m = sz(x[0]);

    if (m == 1)
    {
        ll l = 0, r = 1e9;

        while (l < r)
        {
            ll mdl = (l + r) / 2;

            ll mdr = mdl + 1;

            if (calc(x, mdl) < calc(x, mdr)) r = mdl;
              else l = mdr;
        }

        ll ans = calc(x, l);

        for (int i = 0; i < n; i++)
            x[i][0] = 0;

        allocate_tickets(x);

        return ans;
    }
    else
    {
        ll ans = 0;

        vector <vector <int> > r;

        r.resize(n);

        ll mn = 1e9, mx = 0;

        for (int i = 0; i < n; i++)
        {
            r[i].resize(m);

            for (int j = 0; j < m; j++) {mn = min(mn, x[i][j]); mx = max(mx, x[i][j]); r[i][j] = -1;}
        }

        ll l = mn - 1, rr = mx + 1;

        while (l + 100 < rr)
        {
            ll mdl = l + (rr - l) / 3;

            ll mdr = rr - (rr - l) / 3;

            if (calcer(x, mdl) > calcer(x, mdr)) rr = mdr;
              else l = mdl;
        }

        ans = calcer(x, l);

        ll nm = l;

        for (int i = l; i <= rr; i++)
        {
            ll val = calcer(x, i);

            if (ans < val) {ans = val; nm = i;}
        }

        for (int i = 0; i < sz(x); i++)
            if (x[i][0] <= nm) r[i][0] = 0; else r[i][sz(r[i]) - 1] = 0;

        allocate_tickets(r);

        return ans;
    }
}


//int main()
//{
////    freopen("help.in", "r", stdin); freopen("help.out", "w", stdout);
//
//    ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//
//    cout << find_maximum(1, {{0}, {10}, {3}, {5}, {8}, {1}}) << endl;
//}

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

tickets.cpp: In function 'll find_maximum(int, std::vector<std::vector<int> >)':
tickets.cpp:117:62: error: no matching function for call to 'min(ll&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
  117 |             for (int j = 0; j < m; j++) {mn = min(mn, x[i][j]); mx = max(mx, x[i][j]); r[i][j] = -1;}
      |                                                              ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from tickets.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:198:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  198 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:198:5: note:   template argument deduction/substitution failed:
tickets.cpp:117:62: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
  117 |             for (int j = 0; j < m; j++) {mn = min(mn, x[i][j]); mx = max(mx, x[i][j]); r[i][j] = -1;}
      |                                                              ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from tickets.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:246:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  246 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:246:5: note:   template argument deduction/substitution failed:
tickets.cpp:117:62: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
  117 |             for (int j = 0; j < m; j++) {mn = min(mn, x[i][j]); mx = max(mx, x[i][j]); r[i][j] = -1;}
      |                                                              ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from tickets.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3444:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3444 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3444:5: note:   template argument deduction/substitution failed:
tickets.cpp:117:62: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
  117 |             for (int j = 0; j < m; j++) {mn = min(mn, x[i][j]); mx = max(mx, x[i][j]); r[i][j] = -1;}
      |                                                              ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from tickets.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3450:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3450 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
tickets.cpp:117:62: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
  117 |             for (int j = 0; j < m; j++) {mn = min(mn, x[i][j]); mx = max(mx, x[i][j]); r[i][j] = -1;}
      |                                                              ^
tickets.cpp:117:85: error: no matching function for call to 'max(ll&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
  117 |             for (int j = 0; j < m; j++) {mn = min(mn, x[i][j]); mx = max(mx, x[i][j]); r[i][j] = -1;}
      |                                                                                     ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from tickets.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:222:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  222 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:222:5: note:   template argument deduction/substitution failed:
tickets.cpp:117:85: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
  117 |             for (int j = 0; j < m; j++) {mn = min(mn, x[i][j]); mx = max(mx, x[i][j]); r[i][j] = -1;}
      |                                                                                     ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from tickets.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:268:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  268 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:268:5: note:   template argument deduction/substitution failed:
tickets.cpp:117:85: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
  117 |             for (int j = 0; j < m; j++) {mn = min(mn, x[i][j]); mx = max(mx, x[i][j]); r[i][j] = -1;}
      |                                                                                     ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from tickets.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3456:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3456 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
tickets.cpp:117:85: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
  117 |             for (int j = 0; j < m; j++) {mn = min(mn, x[i][j]); mx = max(mx, x[i][j]); r[i][j] = -1;}
      |                                                                                     ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from tickets.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3462:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3462 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
tickets.cpp:117:85: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
  117 |             for (int j = 0; j < m; j++) {mn = min(mn, x[i][j]); mx = max(mx, x[i][j]); r[i][j] = -1;}
      |                                                                                     ^