QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#795904#9804. Guess the Polygonucup-team3099#WA 2ms3832kbC++233.7kb2024-12-01 03:57:502024-12-01 03:57:50

Judging History

This is the latest submission verdict.

  • [2024-12-01 03:57:50]
  • Judged
  • Verdict: WA
  • Time: 2ms
  • Memory: 3832kb
  • [2024-12-01 03:57:50]
  • Submitted

answer

#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <cassert>
#include <algorithm>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

int main() {
    int t;
    std::cin >> t;
    while(t--) {
        int n;
        std::cin >> n;
        std::vector<int> x(n), y(n);
        for(int i = 0; i < n; i++) {
            std::cin >> x[i] >> y[i];
        }
        std::sort(x.begin(), x.end());
        x.erase(std::unique(x.begin(), x.end()), x.end());
        long double area = 0;
        if((int) x.size() == n) {
            std::vector<long double> sesh(n, 0);
            for(int i = 1; i+1 < n; i++) {
                std::cout << "? " << x[i] << ' ' << 1 << std::endl;
                long long p, q;
                std::cin >> p >> q;
                sesh[i] = p / (long double) q;
            }
            for(int i = 0; i + 1 < n; i++) {
                area += (sesh[i] + sesh[i+1]) / 2 * (x[i+1] - x[i]);
            }
        } else {
            for(int i = 0; i+1 < (int) x.size(); i++) {
                std::cout << "? " << x[i] + x[i+1] << ' ' << 2 << std::endl;
                long long p, q;
                std::cin >> p >> q;
                area += p / (long double) q * (x[i+1] - x[i]);
            }
        }
        int p = (int) (area * 2 + 0.5);
        int q = 2;
        if(p % 2 == 0) {
            p /= 2, q /= 2;
        }
        std::cout << "! " << p << ' ' << q << std::endl;
    }
}

/*
NEVER FORGET TO:
    Look at the problem's constraints before coding.
How to cheese cf:
    Find a lower bound or upper bound for the problem. Have faith that it is the answer of the problem.
    If it isn't the answer, have more faith or change to another bound god by looking for a better bound.

    Trust guesses. Who has time to think? If people in div2 AC the problem it requires no proof since people don't prove things.

    You must draw cases. Thinking gets you nowhere, so draw cases and reach illogical conclusions from them.
    Sometimes drawing cases is bad because it takes too much time. Faster is to not think at all and just code a bruteforce solution.
    This is called "law of small numbers". If something works for small numbers, surely it works for big numbers.
    https://en.wikipedia.org/wiki/Faulty_generalization#Hasty_generalization don't mind the "faulty" part of it, in competitive programming mistakes are lightly punished
    Don't think about them being right or not, cf is a battle of intuition only.

    Be as stupid as possible in implementation. Trying to be smart is an easy way to get WA.

    Think about 2x2 cases for matrix problems and hope that everything works for the general case.

    Find a necessary condition and trust it to be sufficient. They're basically the same thing.

    Heuristics might speed up your code. Forget about complexity, it's only about ACing and not proving that your solution is good.

    For paths in a grid starting at (1, i) or something like that, assume that they never cross and do D&C

    Consider doing problems in reverse order of queries/updates

    For combinatorics problems, consider symmetry

    For problems that are similar to past problems, think about the differences betweem it and the current problem.
    Sometimes the difference makes no difference. Sometimes it does.

General strategy (MUST DO):
    Try to solve the problem with more restricted constraints.

About testing:
    Test n=1, a[i]=1, a[i]=n, etc. Basically, test low values. No need to test if pretests are strong, but if you get WA it's good.

This isn't a joke. Do it if you get stuck. It's shit practice in my opinion, but do it if you want AC.
*/

詳細信息

Test #1:

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

input:

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

output:

? 1 2
? 4 2
! 3 1
? 999 1
! 1999 2

result:

ok correct! (2 test cases)

Test #2:

score: 0
Accepted
time: 1ms
memory: 3576kb

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
5
0 1
1000 1000
1000 0
0 1000
1 0
1999 2
1000 1
9
4 1000
3 1
2 1000
3 1000
1 1
2 1
0 0
1 1000
4 0
500 1
1...

output:

? 1 2
? 4 2
! 5 2
? 1 2
? 4 2
! 7 2
? 1 2
? 4 2
! 3 2
? 1 2
? 4 2
! 2 1
? 1 2
? 4 2
! 5 2
? 1000 2
! 500000 1
? 1000 2
! 1000000 1
? 1 2
? 1001 2
! 1999999 2
? 1 2
? 3 2
? 5 2
? 7 2
! 4003 2

result:

ok correct! (9 test cases)

Test #3:

score: 0
Accepted
time: 2ms
memory: 3832kb

input:

78
8
951 614
927 614
957 614
957 604
937 614
942 619
951 610
927 604
10 1
25 2
21 2
10 1
7
562 260
602 250
582 255
587 260
602 260
562 250
577 260
10 1
15 2
15 2
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
15 1
3
797 264
827 254
857 264
10 1
3
719 737
...

output:

? 1864 2
? 1879 2
? 1893 2
? 1908 2
! 317 1
? 1139 2
? 1159 2
? 1169 2
? 1189 2
! 375 1
? 455 1
! 585 1
? 527 1
! 585 1
? 1748 2
! 600 1
? 827 1
! 300 1
? 1478 2
! 600 1
? 162 1
! 400 1
? 1489 2
? 1499 2
? 1544 2
! 275 1
? 1869 2
? 1879 2
? 1889 2
? 1899 2
? 1909 2
? 1919 2
? 1929 2
? 1939 2
? 1949 ...

result:

ok correct! (78 test cases)

Test #4:

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

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:

? 28 1
? 43 1
? 48 1
? 58 1
? 63 1
? 73 1
? 78 1
? 88 1
? 93 1
? 103 1
? 108 1
? 118 1
? 123 1
? 133 1
? 138 1
? 148 1
? 153 1
? 163 1
? 168 1
? 178 1
? 183 1
? 192 1
! 1925 1
? 54 1
? 69 1
? 74 1
? 84 1
? 89 1
? 99 1
? 104 1
? 114 1
? 119 1
? 129 1
? 134 1
? 144 1
? 149 1
? 159 1
? 164 1
? 174 1
? ...

result:

wrong answer the answer is incorrect, expect: 35226/1, find: 721407/2 (test case 27)