QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#208481 | #6677. Puzzle: Sashigane | PetroTarnavskyi# | WA | 1ms | 3492kb | C++17 | 1.7kb | 2023-10-09 17:37:27 | 2023-10-09 17:37:28 |
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 N = 1 << 19;
struct Point
{
int x, y;
Point() {}
Point(int _x, int _y): x(_x), y(_y) {}
Point operator-(const Point& p) const
{
return {x - p.x, y - p.y};
}
LL operator*(const Point& p) const
{
return (LL)x * p.y - (LL)y * p.x;
}
} p[N];
LL area(int i, int j, int k)
{
LL s = (p[j] - p[i]) * (p[k] - p[i]);
assert(s >= 0);
return s;
}
void solve()
{
int n, k;
cin >> n >> k;
FOR(i, 0, n)
{
cin >> p[i].x >> p[i].y;
p[n + i] = p[i];
p[2 * n + i] = p[i];
}
LL sbc = 0;
FOR(i, 2, k + 1)
sbc += area(0, 1, i);
int ptr = k;
LL res = 0;
FOR(i, 0, n)
{
while (ptr < i + k || (ptr + 1 < n + i && area(i, i + k, ptr + 1) > area(i, i + k, ptr)))
ptr++;
FOR(j, i + k, n + i + 1)
res = max(res, sbc + area(i, i + k, j));
if (i == 2)
{
cerr << i << " " << i + k << " " << ptr << " " << area(i, i + k, ptr) << " " << sbc << endl;
}
res = max(res, sbc + area(i, i + k, ptr));
sbc += area(i, i + k, i + k + 1) - area(i, i + 1, i + k + 1);
}
cout << res / 2;
if (res % 2 == 1)
cout << ".5";
cout << "\n";
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout << fixed << setprecision(15);
int t;
cin >> t;
while (t--)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3492kb
input:
5 3 4
output:
0 0 0 0 0
result:
wrong answer YES or NO expected in answer, but 0 found. (test case 1)