Submission #638428

#TimeUsernameProblemLanguageResultExecution timeMemory
638428LeticiaFCSMobile (BOI12_mobile)C++17
0 / 100
1092 ms98492 KiB
#include "bits/stdc++.h" #define st first #define nd second using lint = int64_t; constexpr int MOD = int(1e9) + 7; constexpr int INF = 0x3f3f3f3f; constexpr int NINF = 0xcfcfcfcf; constexpr lint LINF = 0x3f3f3f3f3f3f3f3f; const long double PI = acosl(-1.0); // Returns -1 if a < b, 0 if a = b and 1 if a > b. int cmp_double(double a, double b = 0, double eps = 1e-9) { return a + eps > b ? b + eps > a ? 0 : 1 : -1; } using namespace std; using ld = long double; int main() { cin.tie(nullptr)->sync_with_stdio(false); int n; lint length; cin>>n>>length; vector<lint> x(n), y(n); for(int i=0; i<n; i++) cin>>x[i]>>y[i]; ld l = 0, r = length; int it = 300; while(it--){ ld mid = (l+r)/2; vector<pair<ld, bool>> intervals; for(int i=0; i<n; i++){ ld xaux = sqrtl(mid*mid - y[i]*y[i]); intervals.push_back({max(ld(0), x[i] - xaux), 0}); intervals.push_back({min(ld(length), x[i] + xaux), 1}); } bool possible = true; sort(intervals.begin(), intervals.end()); intervals.push_back({length, 0}); ld last = 0; int open = 0; for(auto &[position, type]:intervals){ if(type == 0){ if(open == 0 && cmp_double(last, position) == -1){ possible = false; } open++; } else open--; last = position; } if(possible) r = mid; else l = mid; } cout<<fixed<<setprecision(5)<<r<<"\n"; return 0; } /* [ ]Leu o problema certo??? [ ]Ver se precisa de long long [ ]Viu o limite dos fors (é n? é m?) [ ]Tamanho do vetor, será que é 2e5 em vez de 1e5?? [ ]Testar sample [ ]Testar casos de borda [ ]1LL no 1LL << i [ ]Testar mod (é 1e9+7, mesmo?, será que o mod não ficou negativo?) */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...