QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#809135 | #9804. Guess the Polygon | OIer_kzc# | WA | 0ms | 1612kb | C++20 | 1.3kb | 2024-12-11 12:01:59 | 2024-12-11 12:02:00 |
Judging History
answer
#include <stdio.h>
#include <string.h>
#include <queue>
#include <algorithm>
#define LOG(FMT...) fprintf(stderr, FMT)
#define fi first
#define se second
#define em emplace
using namespace std;
typedef long long LL;
constexpr int N = 1005;
LL gcd(LL x, LL y) {
return y ? gcd(y, x % y) : x;
}
struct Frac {
LL x, y;
Frac simp(LL a, LL b) const {
LL d = gcd(a, b);
return (Frac){a / d, b / d};
}
Frac operator + (const Frac &t) const {
return simp(x * t.y + y * t.x, y * t.y);
}
Frac operator * (int t) const {
return simp(x * t, y);
}
Frac operator / (int t) const {
return simp(x, y * t);
}
};
Frac Q(int x) {
printf("? %d 1\n", x);
fflush(stdout);
Frac ret;
scanf("%lld%lld", &ret.x, &ret.y);
return ret;
}
int n;
int xs[N];
Frac v[N];
int main() {
int task;
for (scanf("%d", &task); task--; ) {
scanf("%d", &n);
for (int i = 0, y; i < n; ++i) {
scanf("%d%d", xs + i, &y);
}
sort(xs, xs + n);
for (int i = 1; i < n - 1; ++i) {
v[i] = Q(xs[i]);
}
Frac res;
res = v[0] = v[n - 1] = (Frac){0ll, 1ll};
for (int i = 1; i < n; ++i) {
res = res + (v[i] + v[i - 1]) * (xs[i] - xs[i - 1]) / 2;
}
printf("! %lld %lld\n", res.x, res.y);
fflush(stdout);
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 1612kb
input:
2 4 3 0 1 3 1 1 0 0 2 1 2 1 3 0 0 999 1000 1000 999 1999 1000
output:
? 1 1 ? 1 1 ! 3 1 ? 999 1 ! 1999 2
result:
ok correct! (2 test cases)
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 1580kb
input:
9 4 1 1 1 3 3 0 0 0 3 1 3 1
output:
? 1 1 ? 1 1 ! 9 2
result:
wrong answer the answer is incorrect, expect: 5/2, find: 9/2 (test case 1)