QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#116098#6659. 외곽 순환 도로 2hos_lyric#Compile Error//C++142.1kb2023-06-28 09:32:012024-08-26 15:49:26

Judging History

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

  • [2024-08-26 15:49:26]
  • 管理员手动重测本题所有提交记录
  • [2024-05-31 14:20:34]
  • 评测
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-28 09:32:01]
  • 提交

answer

#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

using Int = long long;

template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }


constexpr Int INF = 1001001001001001001LL;

int N, K;
vector<int> P;
vector<Int> C, W;

Int ans;

namespace sub2 {
void run() {
  assert(K == N - 1);
  // do not use (K-1)-0
  {
    vector<Int> dp(K + 1, INF);
    dp[0] = 0;
    for (int i = 1; i <= K; ++i) {
      if (i - 1 >= 0) chmin(dp[i], dp[i - 1] + W[i - 1]);
      if (i - 2 >= 0) chmin(dp[i], dp[i - 2] + C[i - 1]);
    }
    chmin(ans, dp[K]);
  }
  // use (K-1)-0
  {
    vector<Int> dp(K + 1, INF);
    dp[1] = C[0];
    for (int i = 1; i <= K ++i) {
      if (i - 1 >= 0) chmin(dp[i], dp[i - 1] + W[i - 1]);
      if (i - 2 >= 0) chmin(dp[i], dp[i - 2] + C[i - 1]);
    }
    chmin(ans, dp[K - 1]);
  }
}
}  // sub2

long long place_police(vector<int> P_, vector<long long> C_, vector<long long> W_) {
  P = P_;
  C = C_;
  W = W_;
  N = (int)P.size() + 1;
  K = W.size();
  ans = INF;
  if (P == vector<int>(N - 1, 0)) {
    sub2::run();
  }
  return ans;
}

Details

answer.code: In function ‘void sub2::run()’:
answer.code:61:30: error: expected ‘;’ before ‘i’
   61 |     for (int i = 1; i <= K ++i) {
      |                              ^
      |                              ;