Submission #9089

#TimeUsernameProblemLanguageResultExecution timeMemory
9089mrcamelWall construction (kriii2_WA)C++98
Compilation error
0 ms0 KiB
#include <cstdio> #include <iostream> #include <fstream> #include <deque> #include <algorithm> #include <utility> #include <vector> #include <cmath> #include <queue> using namespace std; #define in cin #define out cout #define PII pair<int, int> #define x first #define y second #define pi 3.14159265358979323846 struct p { double x, y; bool operator <(const p &pa) const { return (x < pa.x) || (x == pa.x && y < pa.y); } }; double cross(const p &O, const p &A, const p &B) { return (A.x - O.x) * (B.y - O.y) - (A.y - O.y) * (B.x - O.x); } vector<p> ch(vector<p> P) { int n = P.size(), k = 0; vector<p> H(2*n); sort(P.begin(), P.end()); for(int i=0; i<n; i++) { while( k>= 2 && cross(H[k-2], H[k-1], P[i]) <= 0) k--; H[k++] = P[i]; } for(int i=n-2, t=k+1; i>=0; i--) { while( k >= t && cross(H[k-2], H[k-1], P[i]) <= 0) k--; H[k++] = P[i]; } H.resize(k); return H; } double getdistance(const p &a, const p &b) { return sqrt( (a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y) ); } int main() { //freopen("in.txt", "r+", stdin); int n; in >> n; double radi; in >> radi; out << fixed; out.precision(15); vector<p> pts; for(int i=0; i<n; i++) { p t; in >> t.x >> t.y; pts.push_back(t); } if(n == 2) {out << getdistance(p[0], p[1])*2 + rad*2*pi; return 0; } double res = 0; int lenp = pts.size()-1; for(int i=0; i<lenp+1; i++) { int a = i-1; if(a < 0) a = lenp; int b = i; int c = i+1; if(b >= lenp) c = 0; p pa = pts[a]; p pb = pts[b]; p pc = pts[c]; res += getdistance(pa, pb); double tan_ab = atan2(pb.y-pa.y, pb.x-pa.x); double tan_bc = atan2(pc.y-pb.y, pc.x-pb.x); if(tan_ab < 0) tan_ab += 2*pi; if(tan_bc < 0) tan_bc += 2*pi; double angle = abs(tan_ab - tan_bc); if(angle > pi) angle = 2*pi - angle; //out << radi*(pi-angle) << endl; res += radi*(pi-angle); } out << res << endl; return 0; }

Compilation message (stderr)

WA.cpp: In function 'int main()':
WA.cpp:77:26: error: expected primary-expression before '[' token
WA.cpp:77:32: error: expected primary-expression before '[' token
WA.cpp:77:41: error: 'rad' was not declared in this scope