QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#704034 | #5537. Storing Eggs | MeatInTheMiddle# | WA | 31ms | 12628kb | C++17 | 3.6kb | 2024-11-02 19:08:52 | 2024-11-02 19:08:59 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define fastio (ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL))
typedef long long ll;
typedef long double lld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
const int MAXSIZE = 2000000;
const long long INF = 1e9 + 5;
const double EPSILON = 1e-14;
const ll DIV = 2000003;
const long double pi = 3.14159265358979323846264338327950288419716939937510L;
int n, k;
string s[3];
int dp[105][10];
double dis[105][105][10][10];
double l;
int cnt;
int solve(int i, int a)
{
if (i == 0)
{
return 0;
}
int &ret = dp[i][a];
if (ret != -1)
return ret;
ret = 0;
if (dis[i][i][a][a] >= l)
{
ret = __builtin_popcount(a);
}
for (int j = 1; j < i; j++)
{
for (int b = 1; b < 8; b++)
{
// cout << dis[j][i][b][a] << " " << l << "\n";
if (dis[j][i][b][a] >= l && dis[j][i][b][a] < INF - EPSILON)
{
ret = max(ret, solve(j, b) + __builtin_popcount(a));
// cout << ret << "\n";
}
}
}
cnt = max(cnt, ret);
return ret;
}
int ok(double t)
{
cnt = 0;
l = t;
memset(dp, -1, sizeof dp);
for (int i = 1; i <= n; i++)
{
for (int j = 1; j < 8; j++)
solve(i, j);
}
// cout << cnt << "\n";
return cnt >= k;
}
int main()
{
fastio;
cin >> n >> k;
int nt = 0;
for (int i = 0; i < 3; i++)
{
cin >> s[i];
for (char j : s[i])
{
if (j == '#')
nt++;
}
s[i] = '1' + s[i];
}
if (3 * n - nt < k)
{
cout << -1;
return 0;
}
fill_n(&dis[0][0][0][0], 105 * 105 * 10 * 10, INF);
for (int i = 1; i <= n; i++)
{
for (int j = i; j <= n; j++)
{
for (int v = 1; v < 8; v++)
{
for (int u = 1; u < 8; u++)
{
if (u == 3 || u == 6 || u == 7)
dis[i][j][v][u] = min(dis[i][j][v][u], (double)1);
if (u == 5)
dis[i][j][v][u] = min(dis[i][j][v][u], (double)2);
for (int a = 0; a < 3; a++)
{
if ((v & (1 << a)) == 0)
continue;
if (s[a][i] == '#')
{
dis[i][j][v][u] = 0;
continue;
}
for (int b = 0; b < 3; b++)
{
if ((u & (1 << b)) == 0)
continue;
if (s[b][j] == '#')
{
dis[i][j][v][u] = 0;
continue;
}
if (i != j)
dis[i][j][v][u] = min(dis[i][j][v][u], sqrt((double)(i - j) * (i - j) + (double)(a - b) * (a - b)));
}
}
// cout << dis[i][j][v][u] << "\n";
}
}
}
}
double l = 1, r = INF;
for (int i = 0; i < 60; i++)
{
double m = (l + r) / (2.0);
if (ok(m))
l = m;
else
r = m;
}
cout.precision(10);
cout << fixed;
cout << l << "\n";
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 12396kb
input:
5 2 #.... ..... ....#
output:
4.4721359546
result:
ok found '4.4721360', expected '4.4721360', error '0.0000000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 12492kb
input:
5 6 ##.## ##### .....
output:
1.0000000000
result:
ok found '1.0000000', expected '1.0000000', error '0.0000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 12628kb
input:
3 4 ..# ... ...
output:
1.4142135618
result:
ok found '1.4142136', expected '1.4142140', error '0.0000003'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3824kb
input:
2 6 .. .# ..
output:
-1
result:
ok found '-1.0000000', expected '-1.0000000', error '-0.0000000'
Test #5:
score: 0
Accepted
time: 2ms
memory: 12528kb
input:
1 2 . . .
output:
1.9999999991
result:
ok found '2.0000000', expected '2.0000000', error '0.0000000'
Test #6:
score: 0
Accepted
time: 18ms
memory: 12496kb
input:
100 2 .................................................................................................... .................................................................................................... ...............................................................................................
output:
99.0201999594
result:
ok found '99.0202000', expected '99.0202000', error '0.0000000'
Test #7:
score: 0
Accepted
time: 20ms
memory: 12460kb
input:
100 3 .................................................................................................... .................................................................................................... ...............................................................................................
output:
49.0407993408
result:
ok found '49.0407993', expected '49.0407990', error '0.0000000'
Test #8:
score: -100
Wrong Answer
time: 31ms
memory: 12484kb
input:
100 100 .................................................................................................... .................................................................................................... .............................................................................................
output:
2.2360679769
result:
wrong answer 1st numbers differ - expected: '2.0000000', found: '2.2360680', error = '0.1180340'