結果

問題 No.173 カードゲーム(Medium)
ユーザー char134217728char134217728
提出日時 2017-12-23 02:48:37
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 278 ms / 3,000 ms
コード長 2,578 bytes
コンパイル時間 2,101 ms
コンパイル使用メモリ 207,048 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-22 15:10:25
合計ジャッジ時間 4,492 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
4,380 KB
testcase_01 AC 27 ms
4,380 KB
testcase_02 AC 235 ms
4,376 KB
testcase_03 AC 237 ms
4,376 KB
testcase_04 AC 231 ms
4,380 KB
testcase_05 AC 207 ms
4,376 KB
testcase_06 AC 177 ms
4,376 KB
testcase_07 AC 164 ms
4,380 KB
testcase_08 AC 162 ms
4,376 KB
testcase_09 AC 278 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:44:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
   44 | main(){
      | ^~~~
main.cpp: 関数 ‘int main()’ 内:
main.cpp:94:18: 警告: ‘scb’ may be used uninitialized [-Wmaybe-uninitialized]
   94 |         sc += sca+scb;
      |               ~~~^~~~
main.cpp:65:23: 備考: ‘scb’ はここで定義されています
   65 |   int sc, su, r, sca, scb;
      |                       ^~~
main.cpp:94:18: 警告: ‘sca’ may be used uninitialized [-Wmaybe-uninitialized]
   94 |         sc += sca+scb;
      |               ~~~^~~~
main.cpp:65:18: 備考: ‘sca’ はここで定義されています
   65 |   int sc, su, r, sca, scb;
      |                  ^~~

ソースコード

diff #

#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) a.begin(),a.end()
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
ll gcd(ll a,ll b){if(a>b)swap(a,b);for(;a>0;b%=a,swap(a,b));return b;}
int modpow(ll a,ll n,int m){if(a==0)return a;ll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(int)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;

int n, pa[21], dai, pb[21], dbi;
double da, db;
vi a, b, aa, bb;

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  random_device rnd;
  mt19937 mt(rnd());
  uniform_int_distribution<> rand[21];
  FOR(i, 2, 21)rand[i] = uniform_int_distribution<>(0, 1000*(i-1)-1);
  cin >> n >> da >> db;
  dai = 1000-round(da*1000);
  dbi = 1000-round(db*1000);
  FOR(i, 2, 21){
    pa[i] = (1000-dai)*(i-1);
    pb[i] = (1000-dbi)*(i-1);
  }
  aa.resize(n);
  FOR(i, 0, n) cin >> aa[i];
  sort(rng(aa));
  bb.resize(n);
  FOR(i, 0, n) cin >> bb[i];
  sort(rng(bb));
  int win = 0;
  int sc, su, r, sca, scb;
  FOR(i, 0, 200000){
    a.resize(n);
    b.resize(n);
    copy(rng(aa), a.begin());
    copy(rng(bb), b.begin());
    sc = 0;
    FORR(j, n, 2){
      r = rand[j](mt);
      su = pa[j];
      FOR(k, 0, j){
        if(su > r){
          sca = a[k];
          a.erase(a.begin()+k);
          break;
        }
        su += dai;
      }
      r = rand[j](mt);
      su = pb[j];
      FOR(k, 0, j){
        if(su > r){
          scb = b[k];
          b.erase(b.begin()+k);
          break;
        }
        su += dbi;
      }
      if(sca > scb){
        sc += sca+scb;
      }else{
        sc -= sca+scb;
      }
    }
    if(a[0] > b[0]){
      sc += a[0]+b[0];
    }else{
      sc -= a[0]+b[0];
    }
    if(sc>0) win++;
  }
  dout(double(win)/200000);
  return 0;
}
0