結果

問題 No.5008 [Cherry Alpha] Discrete Pendulum with Air Resistance
ユーザー Shun_PIShun_PI
提出日時 2022-10-15 01:15:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,938 ms / 2,000 ms
コード長 4,122 bytes
コンパイル時間 2,158 ms
実行使用メモリ 6,952 KB
スコア 1,503,844,387,638,390
最終ジャッジ日時 2022-10-15 01:17:11
合計ジャッジ時間 107,629 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,929 ms
6,948 KB
testcase_01 AC 1,909 ms
4,900 KB
testcase_02 AC 1,916 ms
4,900 KB
testcase_03 AC 1,918 ms
4,900 KB
testcase_04 AC 1,904 ms
4,900 KB
testcase_05 AC 1,904 ms
4,904 KB
testcase_06 AC 1,938 ms
6,952 KB
testcase_07 AC 1,921 ms
4,900 KB
testcase_08 AC 1,905 ms
4,904 KB
testcase_09 AC 1,916 ms
6,948 KB
testcase_10 AC 1,917 ms
4,904 KB
testcase_11 AC 1,910 ms
6,948 KB
testcase_12 AC 1,906 ms
6,948 KB
testcase_13 AC 1,908 ms
4,904 KB
testcase_14 AC 1,908 ms
4,904 KB
testcase_15 AC 1,910 ms
4,900 KB
testcase_16 AC 1,933 ms
4,900 KB
testcase_17 AC 1,918 ms
4,900 KB
testcase_18 AC 1,920 ms
4,904 KB
testcase_19 AC 1,933 ms
4,900 KB
testcase_20 AC 1,905 ms
4,904 KB
testcase_21 AC 1,913 ms
6,952 KB
testcase_22 AC 1,904 ms
4,900 KB
testcase_23 AC 1,929 ms
4,904 KB
testcase_24 AC 1,912 ms
4,904 KB
testcase_25 AC 1,911 ms
4,904 KB
testcase_26 AC 1,923 ms
4,900 KB
testcase_27 AC 1,928 ms
6,948 KB
testcase_28 AC 1,906 ms
6,952 KB
testcase_29 AC 1,910 ms
4,904 KB
testcase_30 AC 1,910 ms
6,952 KB
testcase_31 AC 1,918 ms
4,904 KB
testcase_32 AC 1,916 ms
6,948 KB
testcase_33 AC 1,927 ms
4,908 KB
testcase_34 AC 1,935 ms
4,904 KB
testcase_35 AC 1,908 ms
4,904 KB
testcase_36 AC 1,923 ms
4,900 KB
testcase_37 AC 1,935 ms
4,904 KB
testcase_38 AC 1,923 ms
4,904 KB
testcase_39 AC 1,911 ms
4,900 KB
testcase_40 AC 1,905 ms
4,904 KB
testcase_41 AC 1,935 ms
4,900 KB
testcase_42 AC 1,935 ms
4,904 KB
testcase_43 AC 1,913 ms
6,948 KB
testcase_44 AC 1,907 ms
4,900 KB
testcase_45 AC 1,923 ms
4,908 KB
testcase_46 AC 1,908 ms
4,900 KB
testcase_47 AC 1,907 ms
4,904 KB
testcase_48 AC 1,913 ms
4,904 KB
testcase_49 AC 1,930 ms
6,952 KB
権限があれば一括ダウンロードができます

ソースコード

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 = 37;
bool DEBUG = false;

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);
  srand( time(NULL) );
  if(DEBUG) {
    N = 50;
    K = 50;
  } else cin >> N >> K;
  T = vector<lint>(K);
  U = vector<lint>(K);
  if(DEBUG) {
    while(true) {
      vector<double> F(2*K);
      REP(i, 2*K) F[i] = (double)(rand()) / RAND_MAX;
      vector<lint> G(2*K+1);
      REP(i, 2*K) G[i+1] = round(G[i] + 200.0/F[i]);
      if(G[2*K] > 1e9) continue;
      if(rand() % 2 == 0) {
        REP(i, K) {
          T[i] = G[i*2+1];
          U[i] = G[i*2+2];
        }
      } else {
        REP(i, K) {
          T[i] = G[i*2+2];
          U[i] = G[i*2+1];
        }
      }
      break;
    }

  } else {
    REP(i, K) cin >> T[i];
    REP(i, K) cin >> U[i];
  }
  vector<int> B(N), M(N, 1);
  REP(i, N) B[i] = 1;

  lint best_score = calc_score(B, M);
  cerr << best_score << endl;
  double time = 0;
  int loop = 0;
  double start_temp = 11, end_temp = 9;
  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;
      if(m == 1) b = m + rand() % (2*m);
      if(M[i] != m || B[i] != b) break;
    }
    vector<int> lastM(M), lastB(B);
    if(rand() % 3 < 2) {
      REP(j, N) if(i != j && M[i] == M[j] && B[i] == B[j]) {
        M[j] = m;
        B[j] = b;
      }
    }
    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 = lastM;
      B = lastB;
    }
  }
  
  REP(i, N) cout << B[i] << " " << M[i] << " " << 1000000 << "\n";

}
0