QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#795282#9804. Guess the Polygonucup-team3734#WA 1ms3916kbC++231.5kb2024-11-30 19:13:112024-11-30 19:13:13

Judging History

This is the latest submission verdict.

  • [2024-11-30 19:13:13]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3916kb
  • [2024-11-30 19:13:11]
  • Submitted

answer

#include <bits/stdc++.h>

using namespace std;

typedef long long i64;
typedef unsigned long long u64;
typedef double lf;

const int inf = 1e9 + 100500;

pair<lf, int> getMantissaAndExponent(const string& s) {
    int exponent = (int) s.length();
    string mantissa_digits = s.substr(0, 20);
    string mantissa_str = "0." + mantissa_digits;
    double mantissa = std::stod(mantissa_str);
    return std::make_pair(mantissa, exponent);
}

lf ask(int x) {
    cout << "? " << x << " 1" << endl;
    string p, q;
    cin >> p >> q;
    auto [pm, pe] = getMantissaAndExponent(p);
    auto [qm, qe] = getMantissaAndExponent(q);
    int exp = pe - qe;
    return pm / qm * pow(10, exp);
}

void solve() {
    int n;
    cin >> n;
    vector<int> xs(n);
    for (int i = 0; i < n; ++i) {
        int mycopka;
        cin >> xs[i] >> mycopka;
    }
    sort(xs.begin(), xs.end());
    vector<lf> answers(n, 0);
    for (int i = 1; i + 1 < n; ++i) {
        answers[i] = ask(xs[i]);
    }
    lf S = 0;
    for (int i = 1; i + 1 < n; ++i) {
        S += (xs[i + 1] - xs[i - 1]) * answers[i];
    }
    i64 SS = i64(roundl(S));
    if (SS % 2 == 0) {
        cout << "! " << SS / 2 << " 1" << endl;
    } else {
        cout << "! " << SS << " 2" << endl;
    }
}

signed main() {
#ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    int t = 1;
    cin >> t;
    for (int i = 0; i < t; i++) {
        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

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

result:

ok correct! (2 test cases)

Test #2:

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

input:

9
4
1 1
1 3
3 0
0 0
3 1
3 1

output:

? 1 1
? 1 1
! 9 2

result:

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