QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#501286 | #5153. Delft Distance | pagohia | WA | 0ms | 3908kb | C++14 | 2.0kb | 2024-08-02 16:22:55 | 2024-08-02 16:22:56 |
Judging History
answer
#include<bits/stdc++.h>
#include <unordered_map>
using namespace std;
#define MAXN ((int) 2e5)
const int N = 2890;
const int M = 5e4 + 10;
typedef long long ll;
typedef double db;
typedef pair<int, int>pii;
typedef pair<long, long>pll;
int dx[4] = { 0, 1, 0, -1 }, dy[4] = { 1, 0, -1, 0 };
const int mod = 1e9 + 7;
inline long long read()
{
long long w = 1;
long long q = 0;
char ch = ' ';
while (ch != '-' && (ch < '0' || ch>'9')) ch = getchar();
if (ch == '-') w = -1, ch = getchar();
while (ch >= '0' && ch <= '9')
q = q * 10 + ch - '0', ch = getchar();
return w * q;
}
const long double pr = 7.853981633975;
int n, m;
int s[N][N];
long double ans = 100000.0;
void dfs(int x, int y, int ban, int quan)
{
if (x > 2 * n || y > 2 * m) return;
if (x == 2 * n and y == 2 * m)
{
ans = min(ans, (ban + 1) * 5.0 + quan * pr);
return;
}
if (s[x][y] == 1)
{
dfs(x + 1, y, ban + 1, quan);
dfs(x, y + 1, ban + 1, quan);
}
else if (s[x][y] == 2)
{
dfs(x + 1, y + 1, ban, quan + 1);
dfs(x, y + 1, ban + 1, quan);
}
else if (s[x][y] == -2)
{
dfs(x + 1, y + 1, ban, quan + 1);
dfs(x + 1, y, ban + 1, quan);
}
else if (s[x][y] == -1)
{
dfs(x + 1, y, ban + 1, quan);
dfs(x, y + 1, ban + 1, quan);
}
cout << x << " " << y << endl;
}
void sovle()
{
cin >>n >> m;
for (int i = 1; i <= 2*n; i+=2)
{
for (int j = 1; j <=2* m; j+=2)
{
char ch;
cin >> ch;
if (ch == 'X')
{
s[i][j] = 1;
s[i + 1][j] =1;
s[i][j + 1] = 1;
s[i + 1][j + 1] = 1;
}
else
{
s[i][j] = -1;
s[i + 1][j] = -2;
s[i][j + 1] = 2;
s[i + 1][j + 1] = -1;
}
}
}
dfs(1, 1,0,0);
printf(" % .10lf", ans);
/*for (int i = 1; i <= 2 * n; i++)
{
for (int j = 1; j <= 2 * m; j++)
cout << s[i][j] << " ";
cout << endl;
}*/
}
int main()
{
int tcase= 1;
//cin>>tcase;
while (tcase--)
{
sovle();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3908kb
input:
3 5 XOOXO OXOXO XXXXO
output:
6 9 6 8 6 7 6 6 6 5 6 4 6 3 6 2 6 9 6 8 6 7 6 6 6 5 6 4 6 3 6 9 6 8 6 7 6 6 6 5 6 4 6 9 6 8 6 7 6 6 6 5 6 9 6 8 6 7 6 6 6 9 6 8 6 7 6 9 6 8 6 9 5 10 5 9 5 8 5 7 5 6 5 5 5 4 5 3 5 2 6 9 6 8 6 7 6 6 6 5 6 4 6 3 6 2 6 1 6 9 6 8 6 7 6 6 6 5 6 4...
result:
wrong answer 1st numbers differ - expected: '71.4159265', found: '6.0000000', error = '0.9159851'