Submission #6739938
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
const double dis_max = 1e17;
const int maxn = 2e5 + 5;
int n, s, e;
int l[maxn], r[maxn];
double ans = 0;
double getdis(double a, double b)
{
return sqrt(a * a + b * b);
}
void solve()
{
l[n] = r[n] = e;
int nowy = 0;
double nowx = s;
while (nowy < n)
{
double zuoarc = -dis_max, youarc = dis_max;
int ly = nowy, ry = nowy;
for (int y = nowy + 1; y <= n; y++)
{
double larc = (l[y] - nowx) / (y - nowy), rarc = (r[y] - nowx) / (y - nowy);
if (larc > zuoarc)
{
zuoarc = larc;
ly = y;
}
if (rarc < youarc)
{
youarc = rarc;
ry = y;
}
if (zuoarc >= youarc)
{
if (ly < ry)
{
ans += hypot/*getdis*/(l[ly] - nowx, ly - nowy);
nowy = ly;
nowx = l[ly];
}
else
{
ans += hypot/*getdis*/(r[ry] - nowx, ry - nowy);
nowy = ry;
nowx = r[ry];
}
break;
}
}
}
return;
}
signed main()
{
scanf("%d%d%d", &n, &s, &e);
for (int i = 0; i <= n; i++)
scanf("%d%d", &l[i], &r[i]);
solve();
printf("%0.14lf", ans);
return 0;
}
Submission Info
Submission Time |
|
Task |
D - レースゲーム |
User |
luogu_bot2 |
Language |
C++ (GCC 5.4.1) |
Score |
100 |
Code Size |
1524 Byte |
Status |
AC |
Exec Time |
592 ms |
Memory |
1792 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:57:32: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d%d", &n, &s, &e);
^
./Main.cpp:59:36: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &l[i], &r[i]);
^
Judge Result
Set Name |
All |
Score / Max Score |
100 / 100 |
Status |
|
Set Name |
Test Cases |
All |
00_sample1.txt, 00_sample2.txt, 01_rnd_large_00.txt, 01_rnd_large_01.txt, 01_rnd_large_02.txt, 01_rnd_small_00.txt, 01_rnd_small_01.txt, 01_rnd_small_02.txt, 02_narrowrnd_large_00.txt, 02_narrowrnd_large_01.txt, 02_narrowrnd_small_00.txt, 02_narrowrnd_small_01.txt, 03_zigzag_large_00.txt, 03_zigzag_small_00.txt, 04_middle_large_00.txt, 04_middle_large_01.txt, 04_middle_large_02.txt, 04_middle_small_00.txt, 04_middle_small_01.txt, 04_middle_small_02.txt, 05_turnleft_large_00.txt, 05_turnleft_small_00.txt, 06_turnright_large_00.txt, 06_turnright_small_00.txt, 07_free_large_00.txt, 07_free_small_00.txt |
Case Name |
Status |
Exec Time |
Memory |
00_sample1.txt |
AC |
1 ms |
256 KB |
00_sample2.txt |
AC |
1 ms |
256 KB |
01_rnd_large_00.txt |
AC |
42 ms |
1792 KB |
01_rnd_large_01.txt |
AC |
42 ms |
1792 KB |
01_rnd_large_02.txt |
AC |
42 ms |
1792 KB |
01_rnd_small_00.txt |
AC |
1 ms |
256 KB |
01_rnd_small_01.txt |
AC |
1 ms |
256 KB |
01_rnd_small_02.txt |
AC |
1 ms |
256 KB |
02_narrowrnd_large_00.txt |
AC |
41 ms |
1792 KB |
02_narrowrnd_large_01.txt |
AC |
41 ms |
1792 KB |
02_narrowrnd_small_00.txt |
AC |
1 ms |
256 KB |
02_narrowrnd_small_01.txt |
AC |
1 ms |
256 KB |
03_zigzag_large_00.txt |
AC |
37 ms |
1792 KB |
03_zigzag_small_00.txt |
AC |
1 ms |
256 KB |
04_middle_large_00.txt |
AC |
41 ms |
1792 KB |
04_middle_large_01.txt |
AC |
42 ms |
1792 KB |
04_middle_large_02.txt |
AC |
42 ms |
1792 KB |
04_middle_small_00.txt |
AC |
1 ms |
256 KB |
04_middle_small_01.txt |
AC |
1 ms |
256 KB |
04_middle_small_02.txt |
AC |
1 ms |
256 KB |
05_turnleft_large_00.txt |
AC |
41 ms |
1792 KB |
05_turnleft_small_00.txt |
AC |
1 ms |
256 KB |
06_turnright_large_00.txt |
AC |
592 ms |
1792 KB |
06_turnright_small_00.txt |
AC |
1 ms |
256 KB |
07_free_large_00.txt |
AC |
35 ms |
1792 KB |
07_free_small_00.txt |
AC |
1 ms |
256 KB |