QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#345248 | #3411. Absurdistan Roads | PetroTarnavskyi# | RE | 0ms | 0kb | C++20 | 1.6kb | 2024-03-06 17:52:14 | 2024-03-06 17:52:14 |
answer
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;
const int N = 1147;
const int SZ = 11;
const int MOD = (1 << 11) - 1;
db dp[N][1 << SZ];
int n;
int read()
{
string s;
cin >> s;
if(SZ(s) == 2 || ('0' <= s[0] && s[0] <= '9'))
return stoi(s);
return 10 + (s == "A");
}
bool hasBit(int mask, int bit)
{
return (mask >> bit) & 1;
}
void solve()
{
VI poses;
int pos;
cin >> pos;
pos--;
poses.PB(pos);
FOR(i, 0, n)
{
poses.PB(poses.back() + read());
}
n = poses.back() + 12;
VI ok(n);
for(int i : poses)
ok[i] = 1;
FOR(i, 0, n + 1)
FOR(mask, 0, 1 << SZ)
dp[i][mask] = 0;
dp[n][0] = 1;
RFOR(i, n, 0)
{
FOR(mask, 0, 1 << SZ)
{
int nmask = (mask << i) & MOD;
if(ok[i])
{
dp[i][nmask + 1] += dp[i + 1][mask];
continue;
}
FOR(move, 2, 12)
{
db prob = 1.0 / 13;
if(move == 10)
prob *= 4;
dp[i][nmask + hasBit(mask, prob - 1)] += dp[i + 1][mask] * prob;
}
}
}
db ans = 0;
FOR(i, 0, 10)
{
FOR(mask, 0, 1 << SZ)
{
if(hasBit(mask, 0))
ans += dp[i][mask];
}
}
cout << fixed << setprecision(10) << ans / 10 << "\n";
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
while(cin >> n)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Runtime Error
input:
40 0 49907 81666 63518 54444 18148 77129 45370 9074 86203 77129 36296 58981 13611 86203 58981 4537 90740 40833 27222 36296 4537 45370 22685 68055 72592 68055 63518 72592 81666 22685 31759 54444 40833 18148 9074 31759 13611 27222 49907 49907 0 49907 68055 77129 31759 27222 4537 40833 36296 54444 1361...