diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..57c2030 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "files.associations": { + "algorithm": "cpp" + } +} \ No newline at end of file diff --git a/8.10/C - edge.cpp b/8.10/C - edge.cpp deleted file mode 100644 index 7c44ef2..0000000 --- a/8.10/C - edge.cpp +++ /dev/null @@ -1,105 +0,0 @@ -//weiwancheng -#include -#include -#include -#include -using namespace std; -const double inf=1e100,EPS=1e-6; -const int N=101; -double l,now; -int n; -struct edge -{ - double x[2],y[2]; -} e[N]; -//big bug:double->int -double length(double x1,double y1,double x2,double y2) -{ - double x=x1-x2,y=y1-y2; - return sqrt(x*x+y*y); -} -double cross(double x1,double y1,double x2,double y2) -{ - return x1*y2-x2*y1; -} -double same(double x0,double y0,double x3,double y3,double x1,double y1,double x2,double y2) -{ - double x=x3-x0,y=y3-y0;//y0->x0 - return cross(x,y,x1-x0,y1-y0)*cross(x,y,x2-x0,y2-y0); -} -//WA double 判断正负要用 -int sign(double d) -{ - if(fabs(d)0? 1:-1; -} -bool ob(int li,int lj,int ri,int rj) -{ - for(int i=li+1; i +#include +#include +#include +using namespace std; +const double inf = 1e100, EPS = 1e-8; +const int N = 101; +double l, now; +int n,t; +struct edge +{ + double x[2], y[2]; +} e[N]; +// WA double 判断正负要用 +int sign(double d) +{ + if (fabs(d) < EPS) + { + return 0; + } + else + return d > 0 ? 1 : -1; +} +double cross(double x1, double y1, double x2, double y2) +{ + return x1 * y2 - x2 * y1; +} +int same(double x0, double y0, double x3, double y3, double x1, double y1, double x2, double y2) +{ + double x = x3 - x0, y = y3 - y0; // y0->x0 + //WA? 没有用浮点数的大小比较方法 + return sign(cross(x, y, x1 - x0, y1 - y0)) * sign(cross(x, y, x2 - x0, y2 - y0)); +} +//与所有边比是否相交 +bool ob(int x0, int y0, int x1, int y1) +{ + for (int i = 1; i <= n; i++) + { + if (sign(same(x0,y0,x1,y1,e[i].x[0],e[i].y[0],e[i].x[1],e[i].y[1])) > 0) + { + return 0; + } + } + return 1; +} +//另一线段的点,连点成线 +bool dot2(int ii, int jj) +{ + for (int i = 1; i <= n; i++) + { + if (i == ii) + continue; + for (int j = 0; j < 2; j++) + { + if(sign(e[ii].x[jj]-e[i].x[j])==0&&sign(e[ii].y[jj]-e[i].y[j])==0) continue; + if (ob(e[ii].x[jj], e[ii].y[jj], e[i].x[j], e[i].y[j])) + { + return 1; + } + } + } + return 0; +} +//找一个点 +bool adot() +{ + for (int i = 1; i <= n; i++) + { + for (int j = 0; j < 2; j++) + { + if (dot2(i, j)) + { + return 1; + } + } + } + return 0; +} +int main() +{ + scanf("%d", &t); + while (t--) + { + scanf("%d", &n); + memset(&e, 0, sizeof(edge) * (n + 1)); + for (int i = 1; i <= n; i++) + { + for (int j = 0; j < 2; j++) // 又是j + { + scanf("%lf%lf", &e[i].x[j], &e[i].y[j]);//少一个%lf + } + } + if(n==1) + { + printf("Yes!\n"); + continue; + } + if(adot()) + { + printf("Yes!\n"); + } + else + { + printf("No!\n"); + } + } + return 0; +} diff --git a/8.10/C-edge/Readme.md b/8.10/C-edge/Readme.md new file mode 100644 index 0000000..de8813b --- /dev/null +++ b/8.10/C-edge/Readme.md @@ -0,0 +1,3 @@ +# 标题 + +* 内容 \ No newline at end of file diff --git a/8.10/C-edge/ce.cpp b/8.10/C-edge/ce.cpp new file mode 100644 index 0000000..687a00b --- /dev/null +++ b/8.10/C-edge/ce.cpp @@ -0,0 +1,8 @@ +#include +#include +int main() +{ + + printf("%.0lf",1.4); + return 0; +} diff --git a/8.10/C-edge/doc/Readme.md b/8.10/C-edge/doc/Readme.md new file mode 100644 index 0000000..4e768b5 --- /dev/null +++ b/8.10/C-edge/doc/Readme.md @@ -0,0 +1 @@ +# \ No newline at end of file diff --git a/8.10/C-edge/main.cpp b/8.10/C-edge/main.cpp new file mode 100644 index 0000000..b6d31b7 --- /dev/null +++ b/8.10/C-edge/main.cpp @@ -0,0 +1,6 @@ +#include +using namespace std; +int main() +{ + +} diff --git a/8.10/C-edge/test/in.txt b/8.10/C-edge/test/in.txt new file mode 100644 index 0000000..e69de29 diff --git a/8.10/C-edge/test/in2.txt b/8.10/C-edge/test/in2.txt new file mode 100644 index 0000000..16e6975 --- /dev/null +++ b/8.10/C-edge/test/in2.txt @@ -0,0 +1,12 @@ +3 +2 +1.0 2.0 3.0 4.0 +4.0 5.0 6.0 7.0 +3 +0.0 0.0 0.0 1.0 +0.0 1.0 0.0 2.0 +1.0 1.0 2.0 1.0 +3 +0.0 0.0 0.0 1.0 +0.0 2.0 0.0 3.0 +1.0 1.0 2.0 1.0 \ No newline at end of file diff --git a/8.10/C-edge/test/in3.txt b/8.10/C-edge/test/in3.txt new file mode 100644 index 0000000..e69de29 diff --git a/8.10/C-edge/test/out.txt b/8.10/C-edge/test/out.txt new file mode 100644 index 0000000..01ba092 --- /dev/null +++ b/8.10/C-edge/test/out.txt @@ -0,0 +1,7 @@ +## z:\Chao\src\Template\test\in.txt +2020/03/14 周六 11:41:28.68 +Hello Easy C++ project! + +----------------------------------------------- +Process exited after 200 ms with return value 0 + diff --git a/8.10/E - Intersection.cpp b/8.10/E-Intersection.cpp similarity index 100% rename from 8.10/E - Intersection.cpp rename to 8.10/E-Intersection.cpp diff --git a/8.10/I-Wall/Readme.md b/8.10/I-Wall/Readme.md new file mode 100644 index 0000000..de8813b --- /dev/null +++ b/8.10/I-Wall/Readme.md @@ -0,0 +1,3 @@ +# 标题 + +* 内容 \ No newline at end of file diff --git a/8.10/I-Wall/doc/Readme.md b/8.10/I-Wall/doc/Readme.md new file mode 100644 index 0000000..2257494 --- /dev/null +++ b/8.10/I-Wall/doc/Readme.md @@ -0,0 +1,2 @@ +# 凸包 +*https://www.cnblogs.com/aiguona/p/7232243.html \ No newline at end of file diff --git a/8.10/I-Wall/main.cpp b/8.10/I-Wall/main.cpp new file mode 100644 index 0000000..a76bcc7 --- /dev/null +++ b/8.10/I-Wall/main.cpp @@ -0,0 +1,65 @@ +#include +#include +#include +#include +#include +using namespace std; +const double pi=acos(-1.00),eps = 1e-6;//pi3.14~ +const int N=1001,inf=0x3f3f3f3f; +double ans=0; +struct dot{ + int x,y; +}d[N]; +stacks; +int sign(double d) +{ + if(fabs(d)0? 1:-1; +} +double cross(double x1, double y1, double x2, double y2) +{ + return x1 * y2 - x2 * y1; +} +double length(int x1,int y1,int x2,int y2) +{ + int x=x1-x2,y=y1-y2; + return sqrt((double)x*x+y*y);//CE double +} +int main() +{ + int n,l,minn=1,f,ff,x0,x1,x2,y1,y2,y0; + scanf("%d%d",&n,&l); + for(int i=1;i<=n;i++) + { + scanf("%d%d",&d[i].x,&d[i].y);//&!!! + minn=d[i].y=sign(cross(d[f].x-d[ff].x,d[f].y-d[ff].y,d[j].x-d[ff].x,d[j].y-d[ff].y))) + { + ans-=length(d[f].x,d[f].y,d[ff].x,d[ff].y); +// printf("--%d(%d,%d),%d(%d,%d): -%lf=%lf\n",f,d[f].x,d[f].y,ff,d[ff].x,d[ff].y,length(d[f].x,d[f].y,d[ff].x,d[ff].y),ans); + f=s.top(); + s.pop(); + if(s.empty()) break;//RE + ff=s.top(); + } + ans+=length(d[j].x,d[j].y,d[f].x,d[f].y); +// printf("++%d(%d,%d),%d(%d,%d): +%lf=%lf\n",j,d[j].x,d[j].y,f,d[f].x,d[f].y,length(d[j].x,d[j].y,d[f].x,d[f].y),ans); + s.push(f); + s.push(j); + } +// printf("%d ",s.size()); + printf("%.0lf",ans+2*l*pi);//WA*2 (周长跟多边形形状有关)错了,无关,自带四舍五入 + return 0; +} diff --git a/8.10/I-Wall/test/in.txt b/8.10/I-Wall/test/in.txt new file mode 100644 index 0000000..e69de29 diff --git a/8.10/I-Wall/test/in2.txt b/8.10/I-Wall/test/in2.txt new file mode 100644 index 0000000..e69de29 diff --git a/8.10/I-Wall/test/in3.txt b/8.10/I-Wall/test/in3.txt new file mode 100644 index 0000000..e69de29 diff --git a/8.10/I-Wall/test/out.txt b/8.10/I-Wall/test/out.txt new file mode 100644 index 0000000..01ba092 --- /dev/null +++ b/8.10/I-Wall/test/out.txt @@ -0,0 +1,7 @@ +## z:\Chao\src\Template\test\in.txt +2020/03/14 周六 11:41:28.68 +Hello Easy C++ project! + +----------------------------------------------- +Process exited after 200 ms with return value 0 + diff --git a/8.10/I-Wall/鏍囩▼.cpp b/8.10/I-Wall/鏍囩▼.cpp new file mode 100644 index 0000000..52bfeac --- /dev/null +++ b/8.10/I-Wall/鏍囩▼.cpp @@ -0,0 +1,60 @@ +#include +#include +#include +#include +using namespace std; +const int N = 1e3 + 5; +const double PI = acos(-1.0), eps = 1e-8; +struct Point { + double x, y; + Point () {} + Point (double xx, double yy) : x(xx), y(yy) {} + Point friend operator - (Point a, Point b) { + return Point(a.x - b.x, a.y - b.y); + } + double friend operator ^ (Point a, Point b) { + return a.x * b.y - b.x * a.y; + } + bool friend operator < (Point a, Point b) { + if (a.y == b.y) return a.x < b.x; + return a.y < b.y; + } +} p[N]; +int n, L, q[N]; +double dist (Point a, Point b){ + return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y)); +} +int Sign(double x) { + if (x >= -eps && x <= eps) return 0; + return x > eps ? 1 : -1; +} +bool cmp(Point a, Point b) { + int s = Sign((a - p[1]) ^ (b - p[1])); + if(s > 0 || (s == 0 && dist(a, p[1]) < dist(b, p[1]))) return 1; + else return 0; +} +double Graham() { + sort(p + 1, p + n + 1); + sort(p + 1, p + n + 1, cmp); + int top = 3; + q[1] = 1, q[2] = 2, q[3] = 3; + for (int i = 4; i <= n; i++) { + while(top > 1 && Sign((p[q[top]] - p[q[top - 1]]) ^ (p[i] - p[q[top]])) <= 0) + top--; + q[++top] = i; + } + double res = 0; + for (int i = 1; i < top; i++) + res += dist(p[q[i]], p[q[i + 1]]); + res += dist(p[q[1]], p[q[top]]); + res += 2.0 * PI * L; + return res; +} +int main() { +// freopen("1.txt", "r", stdin); + scanf("%d %d", &n, &L); + for (int i = 1; i <= n; i++) + scanf("%lf %lf", &p[i].x, &p[i].y); + printf("%d\n", (int)(Graham() + 0.5)); + return 0; +}