QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#797857#9804. Guess the Polygonucup-team4975WA 1ms3616kbC++234.2kb2024-12-03 19:50:522024-12-03 19:50:55

Judging History

This is the latest submission verdict.

  • [2024-12-03 19:50:55]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3616kb
  • [2024-12-03 19:50:52]
  • Submitted

answer

#define LOCAL
#include <bits/stdc++.h>
#define fir first
#define sec second
#define el '\n'

#ifdef LOCAL
#define FINISH cerr << "FINISH" << endl;
#else
#define FINISH ;
#endif

#ifdef LOCAL
#define debug(x) cerr << setw(4) << #x << " == " << x << endl
#else
#define debug(x)
#endif

#ifdef LOCAL
#define debugv(x)                   \
    cerr << setw(4) << #x << ":: "; \
    for (auto i : x)                \
        cerr << i << " ";           \
    cerr << endl
#else
#define debugv(x)
#endif

using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
ostream& operator<<(ostream& out, PII& x)
{
    out << x.fir << " " << x.sec << endl;
    return out;
}
#define int long long
typedef long double ld;
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 * 2.0 / y2 - x1 * 1.0 / y1;
            ll len = p[i].x - p[i - 1].x;
            x = x * len;

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

    	int res = p[i].x;
    	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 * 2.0 / y - 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: 100
Accepted
time: 1ms
memory: 3616kb

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
! 1999 2

result:

ok correct! (2 test cases)

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3584kb

input:

9
4
1 1
1 3
3 0
0 0
3 2
1 2
4
0 0
1 3
1 1
3 0
1 2
3 2
4
0 0
3 0
1 2
1 1
1 2
1 2
4
0 0
3 0
1 2
1 1
1 1
1 2
4
0 0
3 0
1 1
1 2
1 2
1 1
3
1000 0
0 0
0 1000
500 1
4
0 0
1000 0
1000 1000
0 1000
1000 1
1000 1
5
0 1
1000 1000
1000 0
0 1000
1 0
2999 3
2999 3
1000 1
9
4 1000
3 1
2 1000
3 1000
1 1
2 1
0 0
1 10...

output:

? 1 2
? 2 1
! 5 2
? 1 2
? 2 1
! 7 2
? 1 2
? 2 1
! 3 2
? 1 2
? 2 1
! 2 1
? 1 2
? 2 1
! 5 2
? 500 1
! 500000 1
? 2000 3
? 2000 3
! 1000000 1
? 2 3
? 2 3
? 1001 2
! 1999999 2
? 1 2
? 5 3
? 5 3
? 8 3
? 8 3
? 11 3
? 11 3
! 2501 1

result:

wrong answer the answer is incorrect, expect: 4003/2, find: 2501/1 (test case 9)