QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#113838 | #5545. Contingency Plan | PetroTarnavskyi# | WA | 1ms | 5716kb | C++17 | 2.0kb | 2023-06-19 17:24:34 | 2023-06-19 17:24:37 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define FOR(i, a, b) for (int i = (a); i<(b); ++i)
#define RFOR(i, b, a) for (int i = (b)-1; i>=(a); --i)
#define MP make_pair
#define PB push_back
#define F first
#define S second
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
const int N = 474;
const int inf = 4747474;
string v[3];
double dp[N][N][8][8];
void setmax(double& a, double b)
{
a = max(a, b);
}
void setmin(double& a, double b)
{
a = min(a, b);
}
double f(int mask1, int mask2, int dis)
{
double ans = inf;
FOR (i, 0, 3)
{
if (((mask1 >> i) & 1) == 0)
continue;
FOR (j, 0, 3)
{
if (((mask2 >> j) & 1) == 0)
continue;
int d1 = abs(i - j);
setmin(ans, sqrt(d1 * d1 + dis * dis));
}
}
if ((mask1 & 3) == 3 || (mask1 & 6) == 6 || (mask2 & 3) == 3 || (mask2 & 6) == 6)
setmin(ans, 1);
if ((mask1 & 5) == 5 || (mask2 & 5) == 5)
setmin(ans, 2);
return ans;
}
bool ok(int m, int i)
{
FOR (j, 0, 3)
{
if (((m >> j) & 1) && v[j][i] == '#')
return false;
}
return true;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int n, k;
cin >> n >> k;
FOR (i, 0, 3)
{
string s;
cin >> s;
v[i] = "#" + s;
}
FOR (i, 0, n + 1)
{
FOR(cnt, 0, k + 1)
{
FOR (m1, 0, 8)
{
FOR (m2, 0, 8)
dp[i][cnt][m1][m2] = inf;
}
}
}
dp[0][0][0][0] = 0;
FOR (now, 1, n + 1)
{
FOR (cnt, 0, k + 1)
{
FOR (col, 0, now)
{
FOR (m, 0, 8)
{
if (!ok(m, now))
continue;
FOR (mask, 0, 8)
{
FOR (pmask, 0, 8)
{
setmax(dp[now][cnt + __builtin_popcount(m)][m][col + 1 == now ? mask : 0], max({dp[col][cnt][mask][pmask], f(mask, m, now - col), f(pmask, m, now - col + 1)}));
}
}
}
}
}
}
double ans = 0;
FOR (i, 0, 8)
{
FOR (j, 0, 8)
{
ans = min(ans, dp[n][k][i][j]);
}
}
cout << ans << '\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5716kb
input:
7 1 2 3 7 2 4 2 5 1 3 3 6
output:
0
result:
wrong output format Unexpected end of file - int32 expected