結果
| 問題 |
No.173 カードゲーム(Medium)
|
| コンテスト | |
| ユーザー |
char134217728
|
| 提出日時 | 2017-12-23 02:48:37 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 277 ms / 3,000 ms |
| コード長 | 2,578 bytes |
| コンパイル時間 | 2,496 ms |
| コンパイル使用メモリ | 203,876 KB |
| 最終ジャッジ日時 | 2025-01-05 06:15:18 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
コンパイルメッセージ
main.cpp:44:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type]
44 | main(){
| ^~~~
main.cpp: In function ‘int main()’:
main.cpp:94:18: warning: ‘sca’ may be used uninitialized [-Wmaybe-uninitialized]
94 | sc += sca+scb;
| ~~~^~~~
main.cpp:65:18: note: ‘sca’ was declared here
65 | int sc, su, r, sca, scb;
| ^~~
main.cpp:94:18: warning: ‘scb’ may be used uninitialized [-Wmaybe-uninitialized]
94 | sc += sca+scb;
| ~~~^~~~
main.cpp:65:23: note: ‘scb’ was declared here
65 | int sc, su, r, sca, scb;
| ^~~
ソースコード
#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;
}
char134217728