QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#343638 | #3067. Justified Jungle | PetroTarnavskyi# | WA | 142ms | 99168kb | C++20 | 1.9kb | 2024-03-02 20:30:15 | 2024-03-02 20:30:16 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef double db;
const int S = 1747;
int f[2][2 * S][2 * S];
void add(int i, int x, int y, int d)
{
f[i][x + S][y + S] += d;
}
int get(int i, int x, int y)
{
if (x < 0 || x >= 2 * S || y < 0 || y >= 2 * S)
return 0;
return f[i][x][y];
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout << fixed << setprecision(2);
int n;
cin >> n;
FOR(i, 0, n)
{
char c;
int x, y, a;
cin >> c >> x >> y >> a;
a /= 2;
if (c == 'A')
{
for (int sx : {-1, 1})
for (int sy : {-1, 1})
add(0, x + sx * a, y + sy * a, sx * sy);
}
else
{
add(1, x - a, y, 1);
add(1, x, y - a, -1);
add(1, x, y + a, -1);
add(1, x + a, y, 1);
}
}
FOR(x, 0, 2 * S)
FOR(y, 1, 2 * S)
f[0][x][y] += f[0][x][y - 1];
FOR(x, 1, 2 * S)
FOR(y, 0, 2 * S)
f[0][x][y] += f[0][x - 1][y];
FOR(x, 1, 2 * S)
RFOR(y, 2 * S - 1, 0)
f[1][x][y] += f[1][x - 1][y + 1];
FOR(x, 1, 2 * S)
FOR(y, 1, 2 * S)
f[1][x][y] += f[1][x - 1][y - 1];
int ans = 0;
FOR(x, 0, 2 * S)
FOR(y, 0, 2 * S)
{
if (f[0][x][y] > 0)
{
ans += 4;
continue;
}
// lower
if (get(1, x, y) > 0 || get(1, x - 1, y - 1) > 0)
ans++;
//left
if (get(1, x - 1, y) > 0 || get(1, x - 1, y + 1) > 0)
ans++;
//upper
if (get(1, x, y + 1) > 0 || get(1, x - 1, y + 1) > 0)
ans++;
//right
if (get(1, x, y) > 0 || get(1, x, y + 1) > 0)
ans++;
}
cout << ans / 4.0 << "\n";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 142ms
memory: 99168kb
input:
8 1 2 2 3 1 4 4 5 6 7 8 3 7 3
output:
11.50
result:
wrong answer 1st lines differ - expected: '1 3 7', found: '11.50'