QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#797784#9804. Guess the Polygonucup-team4975WA 3ms3676kbC++234.2kb2024-12-03 18:15:552024-12-03 18:15:56

Judging History

This is the latest submission verdict.

  • [2024-12-03 18:15:56]
  • Judged
  • Verdict: WA
  • Time: 3ms
  • Memory: 3676kb
  • [2024-12-03 18:15:55]
  • 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
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;
    });	
    ll lasx = 0, lasy = 1;
    ll areax = 0, areay = 1;
    int lft = 0;
    int flag = 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;

	    	ll nxtx = 2 * x2 * y1 - x1 * y2;
	    	ll nxty = y1 * y2;
	    	ll g = __gcd (nxtx, nxty);
	    	nxtx /= g, nxty /= g;
	    	lasx = nxtx, lasy = nxty;

	    	ll x = x2 * y1 + x1 * y2;
	    	ll y = y1 * y2 * 2;
	    	g = __gcd(x, y);
	    	x = x / g, y = y / g;

	    	ll len = p[i].x - p[i - 1].x;
	    	x = x * len;

	    	ll nxtareax = x * areay + y * areax;
	    	ll nxtareay = y * areay;
	    	g = __gcd (nxtareax, nxtareay);
	    	areax = nxtareax / g;
	    	areay = nxtareay / g;

	    	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;

    	ll nxtx = 2 * x * lasy - y * lasx;
    	ll nxty = y * lasy;
    	ll g = __gcd (nxtx, nxty);
    	nxtx /= g, nxty /= g;
    	lasx = nxtx, lasy = nxty;

    	ll len = p[i].x - p[i - 1].x;
    	x = x * len;

    	ll nxtareax = x * areay + y * areax;
    	ll nxtareay = y * areay;
    	g = __gcd (nxtareax, nxtareay);
    	areax = nxtareax / g;
    	areay = nxtareay / g;
    }
    if (p[n].x == p[n - 1].x) {
    	cout << "! " << areax << " " << areay << 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;
    	x = x * len;

    	ll nxtareax = x * areay + y * areax;
    	ll nxtareay = y * areay;
    	ll g = __gcd (nxtareax, nxtareay);
    	areax = nxtareax / g;
    	areay = nxtareay / g;

    	cout << "! " << areax << " " << areay << endl;
    	return;
    }
    ll len = p[n].x - p[n - 1].x;
	ll nxtx = len * lasx;
    ll nxty = 2 * lasy;
    ll g = __gcd (nxtx, nxty);
    nxtx /= g, nxty /= g;
    ll nxtareax = nxty * areax + nxtx * areay;
    ll nxtareay = nxty * areay;
    g = __gcd (nxtareax, nxtareay);
    areax = nxtareax / g;
    areay = nxtareay / g;

    cout << "! " << areax << " " << areay << endl;
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int T = 1;
    cin >> T;
    while (T--) {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3532kb

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: 0
Accepted
time: 1ms
memory: 3676kb

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
2998 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
? 1000 3
? 2000 3
! 1000000 1
? 1 3
? 2 3
? 1001 2
! 1999999 2
? 1 2
? 4 3
? 5 3
? 7 3
? 8 3
? 10 3
? 11 3
! 4003 2

result:

ok correct! (9 test cases)

Test #3:

score: 0
Accepted
time: 3ms
memory: 3596kb

input:

78
8
951 614
927 614
957 614
957 604
937 614
942 619
951 610
927 604
10 1
10 1
25 2
21 2
10 1
10 1
7
562 260
602 250
582 255
587 260
602 260
562 250
577 260
10 1
10 1
15 2
15 2
10 1
3
454 98
494 68
455 68
117 8
3
526 589
566 559
527 559
117 8
3
854 496
854 466
894 466
15 1
3
797 264
827 254
857 264
...

output:

? 2791 3
? 2801 3
? 1879 2
? 1893 2
? 953 1
? 955 1
! 317 1
? 567 1
? 572 1
? 1159 2
? 1169 2
? 1189 2
! 375 1
? 909 2
! 585 1
? 1053 2
! 585 1
? 874 1
! 600 1
? 812 1
! 300 1
? 739 1
! 600 1
? 157 1
! 400 1
? 2231 3
? 2236 3
? 2246 3
? 2251 3
? 2296 3
? 2336 3
! 275 1
? 2801 3
? 2806 3
? 2816 3
? 2...

result:

ok correct! (78 test cases)

Test #4:

score: -100
Wrong Answer
time: 0ms
memory: 3588kb

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
5 3
115 12
35 3
35 3
35 3
35 3
35 3
35 3
35 3
35 3
35 3
35 3
35 3
35 3
35 3
35 3
35 3
35 3
35 3
35 3
35 3
45 4
2...

output:

? 55 2
? 71 2
? 91 2
? 53 1
? 121 2
? 68 1
? 151 2
? 83 1
? 181 2
? 98 1
? 211 2
? 113 1
? 241 2
? 128 1
? 271 2
? 143 1
? 301 2
? 158 1
? 331 2
? 173 1
? 361 2
? 375 2
! 1925 1
? 107 2
? 123 2
? 143 2
? 79 1
? 173 2
? 94 1
? 203 2
? 109 1
? 233 2
? 124 1
? 263 2
? 139 1
? 293 2
? 154 1
? 323 2
? 16...

result:

wrong answer format  Expected int32, but "1775108732385271841" found (test case 27)