QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#795486 | #9804. Guess the Polygon | ucup-team3734# | WA | 1ms | 3768kb | C++23 | 1.9kb | 2024-11-30 20:52:14 | 2024-11-30 20:52:14 |
Judging History
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) {
if (s == "0") {
return {0, 0};
}
int exponent = (int) s.length();
lf mantissa = std::stod("0." + s.substr(0, 40));
return {mantissa, exponent};
}
lf pow10(int x) {
if (x < 0) {
return 1.0 / pow10(-x);
}
lf res = 1;
for (int i = 0; i < x; ++i) {
res *= 10;
}
return res;
}
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 * pow10(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;
vector<lf> sum;
for (int i = 0; i + 1 < n; ++i) {
sum.push_back((xs[i + 1] - xs[i]) * (answers[i + 1] + answers[i]));
}
// for (int i = 1; i + 1 < n; ++i) {
// sum.push_back((xs[i + 1] - xs[i - 1]) * answers[i]);
// }
sort(sum.begin(), sum.end());
S = accumulate(sum.begin(), sum.end(), 0.0);
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: 3768kb
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: 0ms
memory: 3660kb
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)