結果

問題 No.5003 物理好きクリッカー
ユーザー iehn_iehn_
提出日時 2018-12-07 22:19:49
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 340 ms / 10,000 ms
コード長 4,011 bytes
コンパイル時間 1,895 ms
実行使用メモリ 22,008 KB
スコア 1,314,359,707
平均クエリ数 10000.00
最終ジャッジ日時 2021-07-19 09:06:21
合計ジャッジ時間 15,634 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
純コード判定しない問題か言語
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 299 ms
21,516 KB
testcase_01 AC 327 ms
21,540 KB
testcase_02 AC 295 ms
21,684 KB
testcase_03 AC 298 ms
21,852 KB
testcase_04 AC 332 ms
21,360 KB
testcase_05 AC 305 ms
21,540 KB
testcase_06 AC 310 ms
21,480 KB
testcase_07 AC 305 ms
21,528 KB
testcase_08 AC 301 ms
21,372 KB
testcase_09 AC 301 ms
21,876 KB
testcase_10 AC 340 ms
21,372 KB
testcase_11 AC 299 ms
21,372 KB
testcase_12 AC 315 ms
21,840 KB
testcase_13 AC 297 ms
21,876 KB
testcase_14 AC 302 ms
21,372 KB
testcase_15 AC 321 ms
21,696 KB
testcase_16 AC 299 ms
21,372 KB
testcase_17 AC 298 ms
21,696 KB
testcase_18 AC 310 ms
21,540 KB
testcase_19 AC 303 ms
21,864 KB
testcase_20 AC 303 ms
21,888 KB
testcase_21 AC 338 ms
21,552 KB
testcase_22 AC 320 ms
21,360 KB
testcase_23 AC 335 ms
21,876 KB
testcase_24 AC 294 ms
21,360 KB
testcase_25 AC 297 ms
21,348 KB
testcase_26 AC 301 ms
21,540 KB
testcase_27 AC 299 ms
21,876 KB
testcase_28 AC 298 ms
21,504 KB
testcase_29 AC 329 ms
21,888 KB
testcase_30 AC 305 ms
21,372 KB
testcase_31 AC 303 ms
21,924 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// C++11
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <vector>
#include <cmath>
#include "bits/stdc++.h"
#include <sys/time.h>
#include <emmintrin.h>
#include <string>
#include <bitset>

using namespace std;

inline long long GetTSC() {
  long long lo, hi;
  asm volatile ("rdtsc": "=a"(lo), "=d"(hi));
  return lo + (hi << 32);
}
inline double GetSeconds() {
  return GetTSC() / 2.8e9;
}

struct XorShift {
  uint64_t x = 88172645463325252ULL;
  XorShift() {}
  void setSeed(uint64_t seed) { x = seed; }
  uint64_t next() { x ^= x << 13; x ^= x >> 7; x ^= x << 17; return x; }
  int nextInt(int n) {
    uint64_t upper = 0xFFFFFFFFFFFFFFFFULL / n * n;
    uint64_t v = next();
    while (v >= upper) { v = next(); }
    return v % n;
  }
  double nextDouble() {
    uint64_t v = next() >> 11; // 53bit
    return (double)v / (1ULL << 53);
  }
};

const double TO = 9.9;
const double eps = 1e-7;
const double inf = 1e7;
const int N = 10000;
char S[N];
int R[N];
const int CLICK = 1;
const int FM = 6;
const string FS[FM] = {"enhclick", "hand", "lily", "factory", "casino", "grimoire"};
const int FP[FM] = {1, 1, 10, 120, 2000, 25000};
const int FB[FM] = {-1,  150, (int)2e3, (int)3e4, (int)6e5, (int)1e7};
const int FA[FM] = {15, 1500, (int)2e4, (int)3e5, (int)6e6, (int)1e8};
const int BUY = 2;
const int SELL = BUY + FM;
const int REF = BUY + FM * 2;
double starttime, gt;
int tt,ctt;

XorShift xs;

void init(){
  int n;
  scanf("%d%s", &n, S);
}

long calc_score(){
  long r = 0;
  return r;
}


void solve(){
  long c = 0;
  int bcount[FM] = {1, 0, 0, 0, 0, 0};
  int acount[FM] = {0, 0, 0, 0, 0, 0};
  long bcost[FM];
  long acost[FM];
  for(int i=0; i<FM; i++){
    bcost[i] = FB[i];
    acost[i] = FA[i];
  }
  bool sf = 0;
  int ft = -1;
  for(int t=0; t<N; t++){
    int tr = CLICK;
    if(t < N - 1500){
      for(int i=FM-1; i>=0; i--){
        long ac = acost[i];
        long bc = bcost[i];
        if(sf){
          ac -= ac / 10;
          bc -= bc / 10;
        }
        if(ac <= c && bcount[i] > 0){
          tr = REF + i;
          c -= ac;
          acount[i]++;
          acost[i] *= 10;
          break;
        }
        if(i > 0 && bc <= c){
          tr = BUY + i;
          c -= bc;
          bcount[i]++;
          bcost[i] += bcost[i] / 5 + (bcost[i] % 5 ? 1 : 0);
          break;
        }
      }
    }
    R[t] = tr;
    long cc = 0;
    if(tr == CLICK){
      cc = bcount[0] * pow(2, acount[0]);
    }
    for(int i=1; i<FM; i++){
      if(bcount[i] < 1) continue;
      cc += bcount[i] * pow(2, acount[i]) * FP[i];
    }
    if(ft >= t){
      cc *= 7;
    }
    // if(t % 1000 == 999) cerr << t << ": " << c << ", cc: " << cc << endl;
    sf = 0;
    if(S[t] == 'N' || true){
    }else if(S[t] == 'B'){
      c += c / 100 + (c%100 ? 1 : 0);
    }else if(S[t] == 'F'){
      ft = t + 20;
    }else if(S[t] == 'S'){
      sf = 1;
    }
    c += cc;
  }
  for(int i=0; i<FM; i++){
    cerr << "i: " << i << " bc: " << bcount[i] << " ac: " << acount[i] << endl;
  }
  cerr << "c: " << c << endl;
}

void output(){
  int t = 0;
  string s;
  for(int i=0; i<N; i++){
    int ri = R[i];
    if(ri == CLICK){
      cout << "click" << endl;
    }else if(ri == REF){
      cout << "enhclick" << endl;
    }else if(ri >= BUY && ri < BUY + FM){
      cout << "buy " << FS[ri - BUY] << endl;
    }else if(ri >= REF && ri < REF + FM){
      cout << "reinforce " << FS[ri - REF] << endl;
    }else if(ri >= SELL && ri < SELL + FM){
      cout << "sell " << FS[ri - SELL] << endl;
    }
    cin >> s;
    if(i == 0) cerr << "s: " << s << endl;
    if(s == "-4"){
      cerr << 1 / t << endl;
    }
    if(s == "-2") return;
  }
}

int main() {
  srand((unsigned) time(NULL));
  xs.setSeed(rand() % 65536 || 65537);
  double mainstart = GetSeconds();
  cerr << setprecision(10);
  init();
  cerr << "init_time: " << GetSeconds() - mainstart << endl;
  solve();
  output();
  cerr << "main_time: " << GetSeconds() - mainstart << endl;
  return 0;
}
0