답안 #697520

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
697520 2023-02-10T08:13:35 Z vjudge1 Mobile (BOI12_mobile) C++17
0 / 100
34 ms 16544 KB
// euzubillahimineşşeytanirracimbismillahirrahmanirrahim
//    <- bak boşluk tuşun çalışıyo niye kullanmıyon

#include <bits/stdc++.h>
using namespace std;
#define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define fastio() cin.tie(0), ios_base::sync_with_stdio(0)
#define pb push_back
#define pii pair<int ,int>
#define st first
#define nd second
#define sp " "
#define endl "\n"
#define N 1000005
#define int long long

int x[N], y[N];
double l[N], r[N], sq[N];
const int INF = 1e18 + 7;

int32_t main()
{
	#ifndef ONLINE_JUDGE
	fileio();
	#endif
	fastio();

	queue<int> q;
	int n, L;
	cin >> n >> L;
	for (int i = 1; i <= n; i++)
	{
		cin >> x[i] >> y[i];
		sq[i] = x[i] * x[i] + y[i] * y[i];
	}

	q.push(1);
	l[1] = 0, r[1] = L;
	for (int i = 1; i <= n; i++)
	{
		int last = q.front();
		if (x[i] == x[last]) continue;
		l[i] = INF;
		double p = (sq[i] - sq[last]) / (2 * (x[i] - x[last]));
		p = max(p, (double)0);
		while (!q.empty() && p < l[last])
		{
			q.pop();
			if (q.empty()) break;
			last = q.front();
			p = (sq[i] - sq[last]) / (2 * (x[i] - x[last]));
			p = max(p, (double)0);
		}
		if (!q.empty())
		{
			int last = q.front();
			p = (sq[i] - sq[last]) / (2 * (x[i] - x[last]));
			p = max(p, (double)0);
			r[last] = p;
		}
		l[i] = p;
		r[i] = L;
		if (l[i] <= r[i]) q.push(i);
	}

	double ans = 0;
	for (int i = 1; i <= n; i++)
	{
		double gh = abs(x[i] - r[i]);
		double dist = y[i] * y[i] + gh * gh;
		ans = max(ans, dist);
		gh = abs(x[i] - l[i]);
		dist = y[i] * y[i] + gh * gh;
		ans = max(ans, dist);
	}

	double res = sqrt(ans);
	printf("%.5f\n", res);

	cerr<<"time taken : "<<(float)clock() / CLOCKS_PER_SEC<<" seconds\n";
}

Compilation message

mobile.cpp: In function 'int32_t main()':
mobile.cpp:6:25: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 | #define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
      |                  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
mobile.cpp:24:2: note: in expansion of macro 'fileio'
   24 |  fileio();
      |  ^~~~~~
mobile.cpp:6:59: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    6 | #define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
      |                                                    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
mobile.cpp:24:2: note: in expansion of macro 'fileio'
   24 |  fileio();
      |  ^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 30 ms 16460 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 29 ms 16512 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 29 ms 16520 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 29 ms 16460 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 29 ms 16504 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 30 ms 16468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 32 ms 16488 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 30 ms 16512 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 29 ms 16468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 33 ms 16448 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 30 ms 16484 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 29 ms 16420 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 28 ms 16544 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 30 ms 16476 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 29 ms 16512 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 30 ms 16452 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 29 ms 16468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 31 ms 16496 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 30 ms 16472 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 29 ms 16456 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 34 ms 16468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -