結果

問題 No.5008 [Cherry Alpha] Discrete Pendulum with Air Resistance
ユーザー Shun_PIShun_PI
提出日時 2022-10-14 23:52:41
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 3,402 bytes
コンパイル時間 2,191 ms
実行使用メモリ 6,956 KB
スコア 0
最終ジャッジ日時 2022-10-14 23:53:17
合計ジャッジ時間 28,203 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 RE -
testcase_43 RE -
testcase_44 RE -
testcase_45 RE -
testcase_46 RE -
testcase_47 RE -
testcase_48 RE -
testcase_49 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:110:26: 警告: ‘b’ はこの関数内初期化されずに使用されるかもしれません [-Wmaybe-uninitialized]
  110 |       b = m + rand() % (2*b);
      |                        ~~^~~

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr lint B1 = 1532834020;
constexpr lint M1 = 2147482409;
constexpr lint B2 = 1388622299;
constexpr lint M2 = 2147478017;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
template<class T>void chmax(T &a, const T &b) { if (a<b) a=b; }
template<class T>void chmin(T &a, const T &b) { if (b<a) a=b; }
constexpr int TIME_LIMIT = 1900;

vector<lint> T;
vector<lint> U;
lint N, K;
lint MAXM = 7;

lint calc_score(vector<int> &B, vector<int> &M) {
  double score1 = 0;
  REP(i, K) {
    vector<lint> X(N);
    REP(j, N) {
      lint t = B[j] * 2 + M[j] * 2;
      t = T[i] - t;
      t %= M[j] * 4;
      if(t < M[j]) {
        X[j] = t;
      } else if(t < M[j] * 3) {
        X[j] = M[j] * 2 - t;
      } else {
        X[j] = t - M[j] * 4;
      }
    }
    REP(j, N) FOR(k, j+1, N) score1 += (double)abs(X[j] - X[k]) / (B[j] + B[k]);
  }

  double score2 = 0;
  REP(i, K) {
    vector<lint> X(N);
    REP(j, N) {
      lint t = B[j] * 2 + M[j] * 2;
      t = U[i] - t;
      t %= M[j] * 4;
      if(t < M[j]) {
        X[j] = t;
      } else if(t < M[j] * 3) {
        X[j] = M[j] * 2 - t;
      } else {
        X[j] = t - M[j] * 4;
      }
    }
    lint ma = 0;
    REP(j, N) FOR(k, j+1, N) chmax(ma, abs(X[j] - X[k]));
    score2 += 1.0 / sqrt(1.0 + (double)ma / 20.0);
  }
  score1 *= 20000000 / N / (N-1) / K;
  score2 *= 10000000 / K;

  return round(score1) * round(score2);
};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> N >> K;
  T = vector<lint>(K);
  REP(i, K) cin >> T[i];
  U = vector<lint>(K);
  REP(i, K) cin >> U[i];
  vector<int> B(N), M(N, 1);
  REP(i, N) B[i] = i%2 + 1;

  lint best_score = calc_score(B, M);
  cerr << best_score << endl;
  double time = 0;
  int loop = 0;
  double start_temp = 13, end_temp = 10;
  double temp = start_temp;

  auto start_time = std::chrono::system_clock::now();
  
  while(true) {
    if(loop%200 == 0) {
      auto now_time = std::chrono::system_clock::now();
      time = std::chrono::duration_cast<std::chrono::milliseconds>(now_time-start_time).count();
      temp = start_temp + (end_temp - start_temp) * time / (TIME_LIMIT);
      cerr << "LOOP:" << loop << " SCORE:" << best_score << " TIME:" << time << endl;
      if(time > TIME_LIMIT) break;
    }
    loop++;

    int i, b, m;
    while(true) {
      i = rand() % N;
      m = rand() % MAXM + 1;
      b = m + rand() % (2*b);
      if(M[i] != m || B[i] != b) break;
    }
    int lastm = M[i];
    int lastb = B[i];
    M[i] = m;
    B[i] = b;
    lint score = calc_score(B, M);
    double prob = exp(((double)score-best_score)/pow(10, temp));
    if(score > best_score || prob > (rand()%INF)/(double)INF) {
      //ok
      best_score = score;
    } else {
      //ng
      M[i] = lastm;
      B[i] = lastb;
    }
  }
  
  REP(i, N) cout << B[i] << " " << M[i] << " " << 100 << "\n";

}
0