답안 #609882

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
609882 2022-07-28T02:45:05 Z juancarlovieri 조교 (CEOI16_popeala) C++17
컴파일 오류
0 ms 0 KB
  #include <bits/stdc++.h>
  using namespace std;
    
  // #define int long long

  int n, t, s;
  int pts[20005];
  int pre[20005];
  int nxt[55][20005];
  int can[55][20005];
  int dp[20005][55];

  struct Point {
    int x, c;
    int eval (int m) {
      return m * x + c;
    }


  };

  int rek(int cur, int gr) {
    if (cur >= t) {
      if (gr != 0) return 2e9 + 105;
      // if (gr == s) return 2e9 + 105;
      return 0;
    }
    if (gr == 0) return 2e9 + 105;
    int& res = dp[cur][gr];
    if (res != -1) return res;

    res = 2e9 + 105;
    res = min(1ll * res, 1ll * rek(cur + 1, gr - 1) + 1ll * pts[cur] * n);
    vector<int> block;
    for (int i = 0; i < n; ++i) {
      block.push_back(nxt[i][cur]);
    }

    sort(block.begin(), block.end());
    // cout << "LST FOR " << cur << endl;  
    // for (auto i : block) cout << i << ' ';
    //   cout << endl;
    // for (int i = cur; i < t; ++i) {
    //   block.push_back(i);
    // }
    int act = n;
    vector<int> vis(n);
    for (auto i : block) {
      if (i == t) break;
      for (int j = 0; j < n; ++j) {
        if (vis[j]) continue;
        if (nxt[j][i] <= i) {
          vis[j] = 1;
          --act;
        }
      }
      // --act;
      res = min(1ll * res, 1ll * rek(i + 1, gr - 1) + 1ll * (pre[i] - (cur ? (pre[cur - 1]) : 0)) * act);
    // cout << "CUR " << cur << endl;
      // cout << i << ' ' <<   act << ' ' << 1ll * rek(i + 1, gr - 1) + 1ll * (pre[i] - (cur ? (pre[cur - 1]) : 0)) * act << endl;
    }
    // cout << endl;
    res = min(1ll * res, 1ll * rek(t, gr - 1) + 1ll * (pre[t - 1] - (cur ? pre[cur - 1] : 0)) * act);
    // cout << act << endl;
    return res;
  }

  signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    memset(dp, -1, sizeof dp);
    cin >> n >> t >> s;
    for (int i = 0; i < t; ++i) cin >> pts[i];
      pre[0] = pts[0];
    for (int i = 1; i < t; ++i) pre[i] = pre[i - 1] + pts[i];
    for (int i = 0; i < n; ++i) {
      string s;
      cin >> s;
      for (int j = 0; j < t; ++j) {
        if (s[j] == '0') can[i][j] = 0;
        else can[i][j] = 1;
      }
    }

    for (int i = 0; i < n; ++i) {
      nxt[i][t] = t;
      for (int j = t - 1; j >= 0; --j) {
        if (can[i][j] == 0) nxt[i][j] = j;
        else nxt[i][j] = nxt[i][j + 1];
      }
    }
    for (int i = 0; i <= t; ++i) {
      for (int j = 0; j <= s; ++j) {

      dp[i][j] = 2e9 + 105;
      }
    }
    dp[t][0] = 0;
    vector<vector<int>> hasil(t, vector<int>(n + 3, 2e9 + 105));

    for (int gr = 1; gr <= s; ++gr) {
      for (int cur = 0; cur < t; ++cur) {
        int& res = dp[cur][gr];

        res = 2e9 + 105;
        res = min(1ll * res, 1ll * dp[cur + 1][gr - 1] + 1ll * pts[cur] * n);
        vector<int> block;
        for (int i = 0; i < n; ++i) {
          block.push_back(nxt[i][cur]);
        }

        sort(block.begin(), block.end());
        // cout << "LST FOR " << cur << endl;  
        // for (auto i : block) cout << i << ' ';
        //   cout << endl;
        // for (int i = cur; i < t; ++i) {
        //   block.push_back(i);
        // }
        int act = n;
        vector<int> vis(n);
        int last = -1;
        for (auto i : block) {
          if (i == t) break;
          if (last == -1) last = i;
          else {
            // puts("TES");
            res = min(res , hasil[last][act] - 1ll * (((cur) ? (pre[cur - 1]) : 0)) * act);
            // cout << gr << ' ' << act << ' ' << cur << ' ' << i << ' ' << hasil[act][cur] << endl;
            // cout << hasil[act][act] - 1ll * (((cur) ? (pre[cur - 1]) : 0)) * act << endl;
          }
          last = i;
          // for (int j = 0; j < n; ++j) {
          //   if (vis[j]) continue;
          //   if (nxt[j][i] <= i) {
          //     vis[j] = 1;
          //     --act;
          //   }
          // }
          --act;
          res = min(1ll * res, 1ll * dp[i + 1][gr - 1] + 1ll * (pre[i] - (cur ? (pre[cur - 1]) : 0)) * act);
        // cout << "CUR " << cur << endl;
          // cout << i << ' ' <<   act << ' ' << 1ll * rek(i + 1, gr - 1) + 1ll * (pre[i] - (cur ? (pre[cur - 1]) : 0)) * act << endl;
        }
        if (last != -1) {
          res = min(res, hasil[last][act] - 1ll * (((cur) ? (pre[cur - 1]) : 0)) * act);
          //   cout << hasil[act][cur] - 1ll * (((cur) ? (pre[cur - 1]) : 0)) * act << endl;
        }
        // cout << endl;
        res = min(1ll * res, 1ll * dp[t][gr - 1] + 1ll * (pre[t - 1] - (cur ? pre[cur - 1] : 0)) * act);
        // cout << act << endl;
        // return res;
      }
      hasil = vector<vector<int>>(t, vector<int>(n + 3, 2e9 + 105));
      for (int i = t - 1; i >= 0; --i) {
        for (int j = 0; j <= n; ++j) {
          if (i < t - 1) hasil[i][j] = hasil[i + 1][j];
          hasil[i][j] = min(hasil[i][j], dp[i + 1][gr] + j * pre[i]);
        }
      }
    }
    // cout << rek(2, 1) << endl;
    // cout << rek(0, 2) << endl;
    // for (int i = 1; i <= s; ++i) {
    //   cout << rek(0, i) << endl;
    // }
    for (int i = 1; i <= s; ++i) {
      cout << dp[0][i] << endl;
    }
    // cout << rek(0, 0) << endl;
  }

Compilation message

popeala.cpp: In function 'int main()':
popeala.cpp:128:90: error: no matching function for call to 'min(int&, long long int)'
  128 |             res = min(res , hasil[last][act] - 1ll * (((cur) ? (pre[cur - 1]) : 0)) * act);
      |                                                                                          ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from popeala.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
popeala.cpp:128:90: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
  128 |             res = min(res , hasil[last][act] - 1ll * (((cur) ? (pre[cur - 1]) : 0)) * act);
      |                                                                                          ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from popeala.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
popeala.cpp:128:90: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
  128 |             res = min(res , hasil[last][act] - 1ll * (((cur) ? (pre[cur - 1]) : 0)) * act);
      |                                                                                          ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from popeala.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
popeala.cpp:128:90: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
  128 |             res = min(res , hasil[last][act] - 1ll * (((cur) ? (pre[cur - 1]) : 0)) * act);
      |                                                                                          ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from popeala.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
popeala.cpp:128:90: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
  128 |             res = min(res , hasil[last][act] - 1ll * (((cur) ? (pre[cur - 1]) : 0)) * act);
      |                                                                                          ^
popeala.cpp:146:87: error: no matching function for call to 'min(int&, long long int)'
  146 |           res = min(res, hasil[last][act] - 1ll * (((cur) ? (pre[cur - 1]) : 0)) * act);
      |                                                                                       ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from popeala.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
popeala.cpp:146:87: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
  146 |           res = min(res, hasil[last][act] - 1ll * (((cur) ? (pre[cur - 1]) : 0)) * act);
      |                                                                                       ^
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from popeala.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
popeala.cpp:146:87: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
  146 |           res = min(res, hasil[last][act] - 1ll * (((cur) ? (pre[cur - 1]) : 0)) * act);
      |                                                                                       ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from popeala.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
popeala.cpp:146:87: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
  146 |           res = min(res, hasil[last][act] - 1ll * (((cur) ? (pre[cur - 1]) : 0)) * act);
      |                                                                                       ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from popeala.cpp:1:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
popeala.cpp:146:87: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
  146 |           res = min(res, hasil[last][act] - 1ll * (((cur) ? (pre[cur - 1]) : 0)) * act);
      |                                                                                       ^