Submission #535226

# Submission time Handle Problem Language Result Execution time Memory
535226 2022-03-09T17:47:09 Z fcw Balloons (CEOI11_bal) C++17
10 / 100
202 ms 8808 KB
#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;


int main() {
	cin.tie(nullptr)->sync_with_stdio(false);
	int n;
	cin>>n;
	vector<long double>x(n), r(n);
	for(int i=0;i<n;i++) cin>>x[i]>>r[i];
	stack<int>s;
	auto check = [&](int i, int j)->bool{
		return (x[i] - x[j]) * (x[i] - x[j]) + 1e-10 >= 4 * r[i] * r[j];
	};
	for(int i=0;i<n;i++){
		while(!s.empty()){
			if(check(s.top(), i)) break;
			else{
				int j = s.top();
				r[i] = (x[i] - x[j]) * (x[i] - x[j]) /r[j]/ 4;
				if(r[i] >= r[j]) s.pop();
			}
		}
		s.push(i);
	}
	cout<<fixed<<setprecision(3);
	for(int i=0;i<n;i++) cout<<r[i]<<"\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 time Memory Grader output
1 Incorrect 0 ms 204 KB 5th numbers differ - expected: '17.1630000000', found: '99.0000000000', error = '81.8370000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB 3rd numbers differ - expected: '0.0420000000', found: '3.0000000000', error = '2.9580000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 332 KB 114th numbers differ - expected: '39.0180000000', found: '56.0000000000', error = '16.9820000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 31 ms 1100 KB 196th numbers differ - expected: '100.7250000000', found: '111.0000000000', error = '10.2750000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 62 ms 2396 KB 13945th numbers differ - expected: '0.0140000000', found: '7.0000000000', error = '6.9860000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 115 ms 4644 KB 7236th numbers differ - expected: '0.0070000000', found: '7.0000000000', error = '6.9930000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 149 ms 5332 KB 4645th numbers differ - expected: '0.0260000000', found: '8.0000000000', error = '7.9740000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 195 ms 7072 KB 1734th numbers differ - expected: '1856.0220000000', found: '1865.0000000000', error = '8.9780000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 202 ms 8808 KB 2716th numbers differ - expected: '22.1690000000', found: '43.0000000000', error = '20.8310000000'
2 Halted 0 ms 0 KB -