Submission #547063

# Submission time Handle Problem Language Result Execution time Memory
547063 2022-04-09T11:28:28 Z mgl_diamond Balloons (CEOI11_bal) C++14
0 / 100
221 ms 652 KB
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
using ld = long double;
 
#define ii pair<int, int>
#define dd pair<ld, ld>
#define iii pair<int, ii>
#define fi first
#define se second
 
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << "> " << #x << ": " << x << '\n'
 
template<class T> bool maximize(T&a, T b) { if (a<b) return a=b, 1; return 0; }
template<class T> bool minimize(T&a, T b) { if (a>b) return a=b, 1; return 0; }
 
void setIO(string name="") {
	ios::sync_with_stdio(0); cin.tie(0);
	if (name.size()) freopen((name+".in").c_str(), "r", stdin);
	if (name.size()) freopen((name+".out").c_str(), "w", stdout);
}
 
int n;
stack<dd> st;
 
int main() {
	cin >> n;
	for(int i=0; i<n; ++i) {
		ld x, r, prev; cin >> x >> r;
		int cnt=0;
		if (st.size()) {
			prev=st.top().se;
			ld x1=st.top().fi, r1=st.top().se;
			ld val=x1-x;
			minimize(r,	(val*val)/(4*r1));

		}

		while (st.size()) {
			++cnt;
			ld x1=st.top().fi, r1=st.top().se;
			ld val=x1-x;
			minimize(r,	(val*val)/(4*r1));
			if (cnt>1 && r<prev) {
				cout << "FOUND\n";
				return 0;
			}
			if (cnt==1) prev=r1;
			if (r>=r1) st.pop();
			else break;
		}
		st.push({x, r});
	}
	cout << "NOT FOUND\n";
	return 0;
}

Compilation message

bal.cpp: In function 'void setIO(std::string)':
bal.cpp:21:26: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |  if (name.size()) freopen((name+".in").c_str(), "r", stdin);
      |                   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bal.cpp:22:26: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |  if (name.size()) freopen((name+".out").c_str(), "w", stdout);
      |                   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Expected double, but "NOT" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Expected double, but "NOT" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Expected double, but "NOT" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 212 KB Expected double, but "NOT" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 320 KB Expected double, but "NOT" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 52 ms 652 KB Expected double, but "NOT" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 117 ms 488 KB Expected double, but "NOT" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 128 ms 636 KB Expected double, but "NOT" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 158 ms 512 KB Expected double, but "NOT" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 221 ms 368 KB Expected double, but "NOT" found
2 Halted 0 ms 0 KB -