結果
| 問題 |
No.173 カードゲーム(Medium)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-11-08 00:49:58 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 2,501 bytes |
| コンパイル時間 | 788 ms |
| コンパイル使用メモリ | 93,168 KB |
| 最終ジャッジ日時 | 2024-11-14 21:49:21 |
| 合計ジャッジ時間 | 1,188 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp:17:39: error: '::numeric_limits' has not been declared
17 | template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;
| ^~~~~~~~~~~~~~
main.cpp:17:55: error: expected primary-expression before '>' token
17 | template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;
| ^
main.cpp:17:61: error: no matching function for call to 'max()'
17 | template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;
| ~~~~~^~
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/string:50,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/locale_classes.h:40,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/ios_base.h:41,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ios:42,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ostream:38,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/iostream:39,
from main.cpp:1:
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
254 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_algobase.h:254:5: note: template argument deduction/substitution failed:
main.cpp:17:61: note: candidate expects 2 arguments, 0 provided
17 | template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;
| ~~~~~^~
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_algobase.h:300:5: note: candidate: 'templat
ソースコード
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>
static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;
template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;
struct Timer {
ll starttime;
static constexpr ll CYCLES_PER_SEC = 2200000000;
Timer() { starttime = get_cycle(); }
double get() { return (double)(get_cycle()-starttime)/CYCLES_PER_SEC; };
static ll get_cycle() {
u32 a, b;
__asm__ volatile("rdtsc" : "=a"(a), "=d"(b));
return ((ll)a)|((ll)b << 32);
}
};
#include <chrono>
class xor_shift {
uint32_t x, y, z, w;
public:
xor_shift() : x(static_cast<uint32_t>((chrono::system_clock::now().time_since_epoch().count())&((1LL << 32)-1))),
y(1068246329), z(321908594), w(1234567890) {};
uint32_t urand(){
uint32_t t;
t = x ^ (x << 11);
x = y; y = z; z = w;
w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
return w;
};
int rand(int n){
if(n < 0) return -rand(-n);
uint32_t t = numeric_limits<uint32_t>::max()/(n+1)*(n+1);
uint32_t e = urand();
while(e >= t) e = urand();
return static_cast<int>(e%(n+1));
}
int rand(int a, int b){
if(a > b) swap(a, b);
return a+rand(b-a);
}
};
int main() {
int n; double x, y;
cin >> n >> x >> y;
vector<int> a(n), b(n);
for (auto &&i : a) scanf("%d", &i);
for (auto &&j : b) scanf("%d", &j);
sort(a.begin(),a.end());
sort(b.begin(),b.end());
int p = 0, q = 0;
xor_shift rd;
Timer timer;
while(timer.get() < 3){
int score1 = 0, score2 = 0;
vector<int> A = a, B = b;
for (int i = 0; i < n; ++i) {
double s = rd.urand()/4294967295.0, t = rd.urand()/4294967295.0;
if(i == n-1){
(A.back() > B.back() ? score1 : score2) += (A.back() + B.back());
}else {
int cur1 = 0, cur2 = 0;
if(s > x) cur1 = rd.rand(1, n-i-1);
if(t > y) cur2 = rd.rand(1, n-i-1);
(A[cur1] > B[cur2] ? score1 : score2) += (A[cur1] + B[cur2]);
A.erase(A.begin()+cur1);
B.erase(B.begin()+cur2);
}
}
q++;
if(score1 > score2) p++;
}
printf("%.10lf", 1.0*p/q);
return 0;
}