QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#809135#9804. Guess the PolygonOIer_kzc#WA 0ms1612kbC++201.3kb2024-12-11 12:01:592024-12-11 12:02:00

Judging History

This is the latest submission verdict.

  • [2024-12-11 12:02:00]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 1612kb
  • [2024-12-11 12:01:59]
  • Submitted

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;
}

Details

Tip: Click on the bar to expand more detailed information

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)