QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#797016 | #9804. Guess the Polygon | Chinese_zjc_ | WA | 3ms | 3692kb | C++14 | 1.7kb | 2024-12-02 14:19:01 | 2024-12-02 14:19:03 |
Judging History
answer
#include <bits/stdc++.h>
int T, n, cnt[1005];
double query(int p, int eps = 0)
{
std::cout << "? " << p * 1000 + eps << " 1000" << std::endl;
long long a, b;
std::cin >> a >> b;
return 1.0l * a / b;
}
double k(double x1, double y1, double x2, double y2, double x)
{
return (x - x1) / (x2 - x1) * y2 + (x - x2) / (x1 - x2) * y1;
}
signed main()
{
std::ios::sync_with_stdio(false);
std::cin >> T;
while (T--)
{
std::cin >> n;
std::fill(cnt, cnt + 1001, 0);
for (int i = 1, x, y; i <= n; ++i)
std::cin >> x >> y, ++cnt[x];
double sum = 0, lst = 0, lpos = -1, cur = 0;
int pos = 0;
for (int i = 0; i <= 1000; ++i)
{
switch (cnt[i])
{
case 0:
break;
case 1:
cur = pos++ == 0 || pos == n ? 0 : query(i);
sum += k(lpos, lst, i, cur, (std::round(i) + std::round(lpos)) / 2) * (std::round(i) - std::round(lpos));
lst = cur;
lpos = i;
break;
default:
cur = pos == 0 ? 0 : query(i, -1);
sum += k(lpos, lst, i - 0.001, cur, (std::round(i) + std::round(lpos)) / 2) * (std::round(i) - std::round(lpos));
cur = (pos += cnt[i]) == n ? 0 : query(i, +1);
lst = cur;
lpos = i + 0.001;
break;
}
}
long long ans = static_cast<long long>(std::round(sum * 2));
std::cout << "! " << (ans % 2 ? ans : ans / 2) << ' ' << (ans % 2 ? 2 : 1) << std::endl;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3692kb
input:
2 4 3 0 1 3 1 1 0 0 999 500 1999 1000 3 0 0 999 1000 1000 999 1999 1000
output:
? 999 1000 ? 1001 1000 ! 3 1 ? 999000 1000 ! 1999 2
result:
ok correct! (2 test cases)
Test #2:
score: 0
Accepted
time: 1ms
memory: 3668kb
input:
9 4 1 1 1 3 3 0 0 0 2997 1000 1999 2000 4 0 0 1 3 1 1 3 0 999 1000 5997 2000 4 0 0 3 0 1 2 1 1 999 1000 1999 2000 4 0 0 3 0 1 2 1 1 999 500 1999 2000 4 0 0 3 0 1 1 1 2 999 1000 1999 1000 3 1000 0 0 0 0 1000 999999 1000 4 0 0 1000 0 1000 1000 0 1000 1000 1 1000 1 5 0 1 1000 1000 1000 0 0 1000 1 0 999...
output:
? 999 1000 ? 1001 1000 ! 5 2 ? 999 1000 ? 1001 1000 ! 7 2 ? 999 1000 ? 1001 1000 ! 3 2 ? 999 1000 ? 1001 1000 ! 2 1 ? 999 1000 ? 1001 1000 ! 5 2 ? 1 1000 ! 500000 1 ? 1 1000 ? 999999 1000 ! 1000000 1 ? 1 1000 ? 1000 1000 ? 999999 1000 ! 1999999 2 ? 999 1000 ? 1001 1000 ? 1999 1000 ? 2001 1000 ? 2999...
result:
ok correct! (9 test cases)
Test #3:
score: 0
Accepted
time: 3ms
memory: 3608kb
input:
78 8 951 614 927 614 957 614 957 604 937 614 942 619 951 610 927 604 10 1 10 1 15 1 6001 1000 10 1 10 1 7 562 260 602 250 582 255 587 260 602 260 562 250 577 260 10 1 10 1 5 1 10 1 10 1 3 454 98 494 68 455 68 117 4 3 526 589 566 559 527 559 117 4 3 854 496 854 466 894 466 119997 4000 3 797 264 827 2...
output:
? 927001 1000 ? 937000 1000 ? 942000 1000 ? 950999 1000 ? 951001 1000 ? 956999 1000 ! 317 1 ? 562001 1000 ? 577000 1000 ? 582000 1000 ? 587000 1000 ? 601999 1000 ! 375 1 ? 455000 1000 ! 585 1 ? 527000 1000 ! 585 1 ? 854001 1000 ! 600 1 ? 827000 1000 ! 300 1 ? 719001 1000 ! 600 1 ? 162000 1000 ! 400 ...
result:
ok correct! (78 test cases)
Test #4:
score: -100
Wrong Answer
time: 3ms
memory: 3668kb
input:
34 24 123 815 168 800 133 795 27 827 153 805 28 830 178 780 138 810 78 830 192 772 148 790 88 810 43 825 183 795 103 805 163 785 118 800 93 825 63 835 73 815 58 820 198 790 48 840 108 820 10 3 95 6 15 2 95 6 15 2 95 6 15 2 95 6 15 2 95 6 15 2 95 6 15 2 95 6 15 2 95 6 15 2 95 6 15 2 95 6 15 2 15 1 24...
output:
? 28000 1000 ? 43000 1000 ? 48000 1000 ? 58000 1000 ? 63000 1000 ? 73000 1000 ? 78000 1000 ? 88000 1000 ? 93000 1000 ? 103000 1000 ? 108000 1000 ? 118000 1000 ? 123000 1000 ? 133000 1000 ? 138000 1000 ? 148000 1000 ? 153000 1000 ? 163000 1000 ? 168000 1000 ? 178000 1000 ? 183000 1000 ? 192000 1000 !...
result:
wrong answer the answer is incorrect, expect: 35226/1, find: 613890/1 (test case 27)