QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#528462 | #5537. Storing Eggs | Vermeil | WA | 225ms | 5656kb | C++20 | 2.3kb | 2024-08-23 14:40:54 | 2024-08-23 14:40:54 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
typedef long long ll;
using ld = long double;
const int NMAX = 1e5 + 5;
void chmax(int &a, int b){
a = max(a, b);
}
void chmin(int &a, int b){
a = min(a, b);
}
string a[3];
const int inf = 1e9;
int self_dist[8] = {inf, inf, inf, 1, inf, 4, 1, 1};
int adj[8][8];
void f(int b1, int b2){
int res = inf;
for (int i=0;i<3;i++){
if (!(b1 & (1 << i))) continue;
for (int j=0;j<3;j++){
if (!(b2 & (1 << j))) continue;
int d = abs(i - j);
chmin(res, d * d);
}
}
adj[b1][b2] = res;
}
bool valid(int m, int i){
for (int j=0;j<3;j++){
if (a[j][i] == '#' && m & (1 << j)) return false;
}
return true;
}
int n, k;
int dp[111][333][8][8];
int main() {
std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); cout.tie(0);
cin>>n>>k;
for (int i=0;i<3;i++){
cin >> a[i];
a[i] = "#" + a[i];
}
for (int i=0;i<8;i++){
for (int j=0;j<8;j++){
f(i, j);
}
}
dp[0][0][0][0] = inf;
for (int r=1;r<=n;r++){
for (int j=0;j<=r;j++){
for (int l=0;l<r;l++){
for (int b=0;b<8;b++){
if (!valid(b, r)) continue;
for (int b1=0;b1<8;b1++){
if (!b1 && l) continue;
for (int b2=0;b2<8;b2++){
int d = r - l;
int val = dp[l][j][b1][b2];
val = min(val, adj[b1][b] + d * d);
val = min(val, adj[b2][b] + (d + 1) * (d + 1));
val = min(val, self_dist[b]);
chmax(dp[r][j + popcount((unsigned int)b)]
[b][l + 1 == r ? b1 : 0], val);
}
}
}
}
}
}
int ans = 0;
for (int i=0;i<8;i++){
for (int j=0;j<8;j++){
ans = max(ans, dp[n][k][i][j]);
}
}
cout<<fixed<<setprecision(13);
if (!ans) cout<<"-1";
else cout<<sqrt(ans);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3920kb
input:
5 2 #.... ..... ....#
output:
4.4721359549996
result:
ok found '4.4721360', expected '4.4721360', error '0.0000000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
5 6 ##.## ##### .....
output:
1.0000000000000
result:
ok found '1.0000000', expected '1.0000000', error '0.0000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3780kb
input:
3 4 ..# ... ...
output:
1.4142135623731
result:
ok found '1.4142136', expected '1.4142140', error '0.0000003'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3656kb
input:
2 6 .. .# ..
output:
-1
result:
ok found '-1.0000000', expected '-1.0000000', error '-0.0000000'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
1 2 . . .
output:
2.0000000000000
result:
ok found '2.0000000', expected '2.0000000', error '0.0000000'
Test #6:
score: 0
Accepted
time: 217ms
memory: 5572kb
input:
100 2 .................................................................................................... .................................................................................................... ...............................................................................................
output:
99.0201999594022
result:
ok found '99.0202000', expected '99.0202000', error '0.0000000'
Test #7:
score: 0
Accepted
time: 225ms
memory: 5544kb
input:
100 3 .................................................................................................... .................................................................................................... ...............................................................................................
output:
49.0407993409569
result:
ok found '49.0407993', expected '49.0407990', error '0.0000000'
Test #8:
score: 0
Accepted
time: 220ms
memory: 5656kb
input:
100 100 .................................................................................................... .................................................................................................... .............................................................................................
output:
2.0000000000000
result:
ok found '2.0000000', expected '2.0000000', error '0.0000000'
Test #9:
score: -100
Wrong Answer
time: 225ms
memory: 5496kb
input:
100 150 .................................................................................................... .................................................................................................... .............................................................................................
output:
-1
result:
wrong answer 1st numbers differ - expected: '1.4142140', found: '-1.0000000', error = '1.7071066'