Submission #4570
Source Code Expand
#include <iostream> #include <vector> #include <cmath> using namespace std; double get_r(pair<double,double> a, pair<double,double> b) { return sqrt((a.first-b.first)*(a.first-b.first)+(a.second-b.second)*(a.second-b.second)); } int main() { int N; double start, goal; vector<pair<double, double>> course; cin >> N; cin >> start >> goal; for(int i=0;i<=N;++i) { double l,r; cin >> l >> r; course.push_back({l,r}); } double result = 0.0; pair<double,double> begin = {start, 0}; pair<double,double> end = {goal, N}; for(int i=0;i<=N;++i) { double pos = begin.first + (begin.first - end.first) /(begin.second - end.second) *(static_cast<double>(i)-begin.second); if(pos>=course[i].first && pos<=course[i].second) continue; pair<double,double> tmp; if(pos<course[i].first) tmp = {course[i].first, i}; if(pos>course[i].second) tmp = {course[i].second, i}; result += get_r(begin, tmp); begin = tmp; } result += get_r(begin, end); printf("%.14f\n", result); return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - レースゲーム |
User | kyubuns |
Language | C++ (GCC 4.4.7) |
Score | 0 |
Code Size | 1101 Byte |
Status | CE |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:15: error: ‘>>’ should be ‘> >’ within a nested template argument list ./Main.cpp:22: warning: extended initializer lists only available with -std=c++0x or -std=gnu++0x ./Main.cpp:22: warning: extended initializer lists only available with -std=c++0x or -std=gnu++0x ./Main.cpp:26: error: in C++98 ‘begin’ must be initialized by constructor, not by ‘{...}’ ./Main.cpp:26: warning: extended initializer lists only available with -std=c++0x or -std=gnu++0x ./Main.cpp:27: error: in C++98 ‘end’ must be initialized by constructor, not by ‘{...}’ ./Main.cpp:27: warning: extended initializer lists only available with -std=c++0x or -std=gnu++0x ./Main.cpp:27: error: narrowing conversion of ‘N’ from ‘int’ to ‘double’ inside { } ./Main.cpp:36: warning: extended initializer lists only available with -std=c++0x or -std=gnu++0x ./Main.cpp:36: warning: extended initializer lists only available with -std=c++0x or -std=gnu++0x ./Main.cpp:36:...