QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#174925 | #5537. Storing Eggs | LittleCube | WA | 252ms | 4048kb | C++14 | 2.6kb | 2023-09-10 14:44:05 | 2023-09-10 14:44:05 |
Judging History
answer
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define F first
#define S second
using namespace std;
int N, K, dp[105][4][4][4];
string s[3];
vector<int> masks[6] = {{},
{1, 2, 3, 4, 5, 6, 7},
{1, 2, 4, 5},
{1, 2, 4, 5},
{1, 2, 4, 5},
{1, 2, 4}};
void chmax(int &a, int b)
{
a = max(a, b);
}
int check(int d)
{
int res = 0;
for (int i = 1; i <= N; i++)
for (int a : {0, 1, 2, 3})
for (int b : {0, 1, 2, 3})
for (int c : {0, 1, 2, 3})
dp[i][a][b][c] = 0;
for (int i = 1; i <= N; i++)
for (int mask : masks[min(5, d)])
for (int j = 0; j < i; j++)
{
bitset<3> t = mask;
if (!j)
chmax(dp[i][t[0] ? 0 : 3][t[1] ? 0 : 3][t[2] ? 0 : 3], __builtin_popcount(mask));
for (int a : {0, 1, 2, 3})
for (int b : {0, 1, 2, 3})
for (int c : {0, 1, 2, 3})
{
vector<pii> u = {pii(0, j - a), pii(1, j - b), pii(2, j - c)};
bool flag = 1;
for (int k = 0; k < 3; k++)
if (t[k])
{
if (s[k][i - 1] == '#')
flag = 0;
for (auto [x, y] : u)
if ((x - k) * (x - k) + (y - i) * (y - i) < d)
flag = 0;
}
if (flag)
chmax(dp[i][t[0] ? 0 : min(3, a + i - j)][t[1] ? 0 : min(3, b + i - j)][t[2] ? 0 : min(3, c + i - j)], dp[j][a][b][c] + __builtin_popcount(mask));
}
}
for (int i = 1; i <= N; i++)
for (int a : {0, 1, 2, 3})
for (int b : {0, 1, 2, 3})
for (int c : {0, 1, 2, 3})
res = max(res, dp[i][a][b][c]);
return res;
}
signed main()
{
cin >> N >> K;
for (int i = 0; i < 3; i++)
cin >> s[i];
int l = 0, r = 100 * 100 + 4;
while (l < r)
{
int mid = (l + r + 1) / 2;
if (check(mid) >= K)
l = mid;
else
r = mid - 1;
}
if (r == 0)
cout << -1 << '\n';
else
cout << fixed << setprecision(10) << sqrtl(l) << '\n';
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 3872kb
input:
5 2 #.... ..... ....#
output:
4.4721359550
result:
ok found '4.4721360', expected '4.4721360', error '0.0000000'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3812kb
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: 4048kb
input:
3 4 ..# ... ...
output:
1.4142135624
result:
ok found '1.4142136', expected '1.4142140', error '0.0000003'
Test #4:
score: 0
Accepted
time: 2ms
memory: 3812kb
input:
2 6 .. .# ..
output:
-1
result:
ok found '-1.0000000', expected '-1.0000000', error '-0.0000000'
Test #5:
score: 0
Accepted
time: 2ms
memory: 3880kb
input:
1 2 . . .
output:
2.0000000000
result:
ok found '2.0000000', expected '2.0000000', error '0.0000000'
Test #6:
score: 0
Accepted
time: 181ms
memory: 3844kb
input:
100 2 .................................................................................................... .................................................................................................... ...............................................................................................
output:
99.0201999594
result:
ok found '99.0202000', expected '99.0202000', error '0.0000000'
Test #7:
score: 0
Accepted
time: 207ms
memory: 3960kb
input:
100 3 .................................................................................................... .................................................................................................... ...............................................................................................
output:
49.0407993410
result:
ok found '49.0407993', expected '49.0407990', error '0.0000000'
Test #8:
score: 0
Accepted
time: 217ms
memory: 3828kb
input:
100 100 .................................................................................................... .................................................................................................... .............................................................................................
output:
2.0000000000
result:
ok found '2.0000000', expected '2.0000000', error '0.0000000'
Test #9:
score: 0
Accepted
time: 228ms
memory: 3772kb
input:
100 150 .................................................................................................... .................................................................................................... .............................................................................................
output:
1.4142135624
result:
ok found '1.4142136', expected '1.4142140', error '0.0000003'
Test #10:
score: 0
Accepted
time: 252ms
memory: 3992kb
input:
100 151 .................................................................................................... .................................................................................................... .............................................................................................
output:
1.0000000000
result:
ok found '1.0000000', expected '1.0000000', error '0.0000000'
Test #11:
score: 0
Accepted
time: 252ms
memory: 3888kb
input:
100 200 .................................................................................................... .................................................................................................... .............................................................................................
output:
1.0000000000
result:
ok found '1.0000000', expected '1.0000000', error '0.0000000'
Test #12:
score: 0
Accepted
time: 249ms
memory: 3964kb
input:
100 201 .................................................................................................... .................................................................................................... .............................................................................................
output:
1.0000000000
result:
ok found '1.0000000', expected '1.0000000', error '0.0000000'
Test #13:
score: 0
Accepted
time: 90ms
memory: 3888kb
input:
60 130 ............................................................ ............................................................ ............................................................
output:
1.0000000000
result:
ok found '1.0000000', expected '1.0000000', error '0.0000000'
Test #14:
score: 0
Accepted
time: 210ms
memory: 3960kb
input:
100 100 .................................................................................................... #################################################################################################### .............................................................................................
output:
2.0000000000
result:
ok found '2.0000000', expected '2.0000000', error '0.0000000'
Test #15:
score: -100
Wrong Answer
time: 199ms
memory: 3824kb
input:
100 51 #################################################################################################### .................................................................................................... ###########################################################################################...
output:
2.0000000000
result:
wrong answer 1st numbers differ - expected: '1.0000000', found: '2.0000000', error = '1.0000000'