QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#798072#9804. Guess the Polygonucup-team4975WA 1ms3576kbC++233.8kb2024-12-04 01:20:562024-12-04 01:20:57

Judging History

This is the latest submission verdict.

  • [2024-12-04 01:20:57]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3576kb
  • [2024-12-04 01:20:56]
  • Submitted

answer

#define LOCAL
#include <bits/stdc++.h>
#define fir first
#define sec second
#define el '\n'
#define int long long
using namespace std;
typedef long double ld;
typedef long long ll;

const int mod = 998244353;
const int inf = 0x3f3f3f3f;
const int N = 200020;
struct point {
    int x, y;
};
void solve()
{
    int n;
    cin >> n;
    vector<point> p(n + 1);
    for (int i = 1; i <= n; i++) {
        cin >> p[i].x >> p[i].y;
    }
    sort(next(p.begin()), p.end(), [&](point x, point y) {
        return x.x < y.x;
    }); 

    int flag = 0;
    ld las = 0, area = 0;
    for (int i = 2; i < n; i++) {
        if (p[i].x == p[i - 1].x) {
            flag = 1;
            continue;
        }
        
        if (flag == 1) {
            flag = 0;
            int x1, y1, x2, y2;
            if ((p[i].x + 2 * p[i - 1].x) % 3 == 0) {
                cout << "? " << (p[i].x + 2 * p[i - 1].x) / 3 << " " << 1 << endl;
            }
            else {
                cout << "? " << (p[i].x + 2 * p[i - 1].x) << " " << 3 << endl;
            }
            cin >> x1 >> y1;
            if ((2 * p[i].x + p[i - 1].x) % 3 == 0) {
                cout << "? " << (2 * p[i].x + p[i - 1].x) / 3 << " " << 1 << endl;
            }
            else {
                cout << "? " << (2 * p[i].x + p[i - 1].x) << " " << 3 << endl;
            }
            cin >> x2 >> y2;

            ld x = (x1 * 1.0 / y1 + x2 * 1.0 / y2) * 0.5;
            ld nxt = x2 / y2* 2.0  - x1 * 1.0 / y1;
            ll len = p[i].x - p[i - 1].x;
            x = x * len;

            area += x;
            las = nxt;
            continue;
        }

        if ((p[i].x + p[i - 1].x) % 2 == 0) {
            cout << "? " << (p[i].x + p[i - 1].x) / 2 << " " << 1 << endl;
        }
        else {
            cout << "? " << (p[i].x + p[i - 1].x) << " " << 2 << endl;
        }
        ll x, y;
        cin >> x >> y;

        ld nxt = x / y * 2.0 - las;
        ll len = p[i].x - p[i - 1].x;
        ld xx = 1.0 * x / y * len;

        area += xx;
        las = nxt;
    }

    
    if (p[n].x == p[n - 1].x) {
        if (area - ll(area) <= 0.25) {
            cout << "! " << ll(area) << " 1" << endl;
        }
        else if (area - (ll)area >= 0.75){
            cout << "! " << ll(area + 0.5) << " 1" << endl;
        }
        else {
            area = area * 2;
            cout << "! " << ll(area + 0.5) << " 2" << endl;
        }
        return;
    }
    if (flag == 1) {
        if ((p[n].x + p[n - 1].x) % 2 == 0) {
            cout << "? " << (p[n].x + p[n - 1].x) / 2 << " " << 1 << endl;
        }
        else {
            cout << "? " << (p[n].x + p[n - 1].x) << " " << 2 << endl;
        }
        ll x, y;
        cin >> x >> y;

        ll len = p[n].x - p[n - 1].x;
        ld xx = 1.0 * x / y * len;
        area += xx;


        if (area - ll(area) <= 0.25) {
            cout << "! " << ll(area) << " 1" << endl;
        }
        else if (area - (ll)area >= 0.75){
            cout << "! " << ll(area + 0.5) << " 1" << endl;
        }
        else {
            area = area * 2;
            cout << "! " << ll(area + 0.5) << " 2" << endl;
        }
        return;
    }

    ll len = p[n].x - p[n - 1].x;

    area += 0.5 * las * len;
    if (area - ll(area) <= 0.25) {
        cout << "! " << ll(area) << " 1" << endl;
    }
    else if (area - (ll)area >= 0.75){
        cout << "! " << ll(area + 0.5) << " 1" << endl;
    }
    else {
        area = area * 2;
        cout << "! " << ll(area + 0.5) << " 2" << endl;
    }
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int T = 1;
    cin >> T;
    while (T--) {
        solve();
    }
    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3576kb

input:

2
4
3 0
1 3
1 1
0 0
1 1
1 1
3
0 0
999 1000
1000 999
1999 2000

output:

? 1 2
? 2 1
! 3 1
? 999 2
! 1997 2

result:

wrong answer the answer is incorrect, expect: 1999/2, find: 1997/2 (test case 2)