题目链接  Codeforces_Gym_101177

Problem A  Anticlockwise Motion

直接模拟即可

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>
using namespace std;
int a,b;
pair<int,int> p1,p2;
pair<int,int> calc(int x)
{pair<int,int> ans;int y=sqrt(x*1.0);if ((y&1)&&(y*y==x)){ans.first=ans.second=(-(y-1)>>1);return ans;}if ((y&1)==0) y--;int p=y*y;ans.first=ans.second=(-(y-1)>>1);if (x-p<=(y+1)){ans.second--;ans.first+=(x-p)-1;return ans;}p+=(y+1);ans.first+=y;ans.second--;if (x-p<=y+1){ans.second+=(x-p);return ans;}ans.second+=(y+1);p+=(y+1);if (x-p<=y+1){ans.first-=(x-p);return ans;}ans.first-=(y+1);p+=y+1;ans.second-=(x-p);return ans;
}
int main()
{scanf("%d%d",&a,&b);p1=calc(a);p2=calc(b);printf("%d\n",abs(p1.first-p2.first)+abs(p1.second-p2.second));return 0;
}

Problem D Dendroctonus

非正解

任意选取三个点确定一个圆然后判断。

但是这样有特殊情况……如果两个点和另一个很远的点构成一个很大的圆,

这个圆可能恰好符合题意。

所以我们再加入8个坐标足够大的点再枚举判断就可以了。

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>
using namespace std;
#define y1 khjk
#define y2 kjkj
struct point
{double x,y;point(){}point(double _x,double _y):x(_x),y(_y){}point operator -(const point &b) const{return point(x-b.x,y-b.y);}double operator *(const point &b) const{return x*b.x+y*b.y;}double operator ^(const point &b) const{return x*b.y-y*b.x;}
};
struct line
{point s,e;double a,b,c;line(){}line (point _s,point _e):s(_s),e(_e){a=e.y-s.y;b=s.x-e.x;c=e.x*s.y-s.x*e.y;}
};
double xmult(point p0,point p1,point p2)
{return (p1-p0)^(p2-p0);
}
const double eps = 1e-1;
double sgn(double x)
{if(fabs(x) < eps)return 0;if(x < 0)return -1;else return 1;
}
bool inter(line l1,line l2)
{returnmax(l1.s.x,l1.e.x) >= min(l2.s.x,l2.e.x) &&max(l2.s.x,l2.e.x) >= min(l1.s.x,l1.e.x) &&max(l1.s.y,l1.e.y) >= min(l2.s.y,l2.e.y) &&max(l2.s.y,l2.e.y) >= min(l1.s.y,l1.e.y) &&sgn((l2.s-l1.s)^(l1.e-l1.s))*sgn((l2.e-l1.s)^(l1.e-l1.s)) <= 0 &&sgn((l1.s-l2.s)^(l2.e-l2.s))*sgn((l1.e-l2.s)^(l2.e-l2.s)) <= 0;
}
bool samepoint(point p1,point p2)
{if (fabs(p1.x-p2.x)>eps) return false;if (fabs(p1.y-p2.y)>eps) return false;return true;
}
double cross(point sp,point ep,point op)
{return (sp.x-op.x)*(ep.y-op.y)-(sp.y-op.y)*(ep.x-op.x);
}
double area(point p1,point p2,point p3)
{return fabs(cross(p1,p2,p3))/2;
}
point intersection(line u,line v)
{point p;p.x=(cross(v.e,u.e,u.s)*v.s.x-cross(v.s,u.e,u.s)*v.e.x)/(cross(v.e,u.e,u.s)-cross(v.s,u.e,u.s));p.y=(cross(v.e,u.e,u.s)*v.s.y-cross(v.s,u.e,u.s)*v.e.y)/(cross(v.e,u.e,u.s)-cross(v.s,u.e,u.s));return p;
}
point interpoint(line l1, line l2)
{point tmp;if(fabs(l1.b)<eps){tmp.x=-l1.c/l1.a;tmp.y=(-l2.c-l2.a*tmp.x)/l2.b;}else{tmp.x=(l1.c*l2.b-l1.b*l2.c)/(l1.b*l2.a-l2.b*l1.a);tmp.y=(-l1.c-l1.a*tmp.x)/l1.b;}return tmp;
}
double findx(double y,line l)
{return (-l.c-l.b*y)/l.a;
}
double findy(double x,line l)
{if (fabs(l.b)<eps)return -1e250;return (-l.c-l.a*x)/l.b;
}
point tcircle(point pt1, point pt2, point pt3, double &radius)
{double x1 = pt1.x, x2 = pt2.x, x3 = pt3.x;double y1 = pt1.y, y2 = pt2.y, y3 = pt3.y;double a = x1 - x2;double b = y1 - y2;double c = x1 - x3;double d = y1 - y3;double e = ((x1 * x1 - x2 * x2) + (y1 * y1 - y2 * y2)) / 2.0;double f = ((x1 * x1 - x3 * x3) + (y1 * y1 - y3 * y3)) / 2.0;double det = b * c - a * d;if( fabs(det) <eps){radius = -1;return point(0,0);}double x0 = -(d * e - b * f) / det;double y0 = -(a * f - c * e) / det;radius = hypot(x1 - x0, y1 - y0);return point(x0, y0);
}
int n,cnt1=0,cnt2=0;
point p1[1100],p2[1100];
double dis(point p1,point p2)
{return sqrt((p2.x-p1.x)*(p2.x-p1.x)+(p2.y-p1.y)*(p2.y-p1.y));
}
void calc(point P,point Q)
{double r=dis(P,Q)/2;point p;p.x=(P.x+Q.x)/2;p.y=(P.y+Q.y)/2;bool can=true;int l;for (l=1;l<=cnt1;l++)if ((p1[l].x-p.x)*(p1[l].x-p.x)+(p1[l].y-p.y)*(p1[l].y-p.y)-r*r>eps){can=false;break;}if (!can) return;for (l=1;l<=cnt2;l++)if (r*r-(p2[l].x-p.x)*(p2[l].x-p.x)-(p2[l].y-p.y)*(p2[l].y-p.y)>eps){can=false;break;}if (can){puts("No");exit(0);}}
bool onSegment(point Pi , point Pj , point Q)
{if((Q.x - Pi.x) * (Pj.y - Pi.y) == (Pj.x - Pi.x) * (Q.y - Pi.y)&& min(Pi.x , Pj.x) <= Q.x && Q.x <= max(Pi.x , Pj.x)&& min(Pi.y , Pj.y) <= Q.y && Q.y <= max(Pi.y , Pj.y))return true;elsereturn false;
}
int main()
{scanf("%d",&n);int i,j,k,l;for (i=1;i<=n;i++){point p;scanf("%lf%lf",&p.x,&p.y);char c[3];scanf("%s",c);if (c[0]=='I')p1[++cnt1]=p;else p2[++cnt2]=p;}if (cnt1<=1){puts("No");return 0;}else if (cnt1==2){calc(p1[1],p1[2]);bool can=true;for (i=1;i<=cnt2;i++)if (onSegment(p1[1],p1[2],p2[i])){can=false;break;}if (can)puts("No");else puts("Yes");return 0;}int cnt3=cnt1;cnt3++;p1[cnt3].x=10000;p1[cnt3].y=10000;cnt3++;p1[cnt3].x=-10000;p1[cnt3].y=10000;cnt3++;p1[cnt3].x=10000;p1[cnt3].y=-10000;cnt3++;p1[cnt3].x=-10000;p1[cnt3].y=-10000;cnt3++;p1[cnt3].x=0;p1[cnt3].y=-10000;cnt3++;p1[cnt3].x=0;p1[cnt3].y=10000;cnt3++;p1[cnt3].x=10000;p1[cnt3].y=0;cnt3++;p1[cnt3].x=-10000;p1[cnt3].y=-0;for (i=1;i<=cnt3-2;i++)for (j=i+1;j<=cnt3-1;j++)for (k=j+1;k<=cnt3;k++){double r;point p=tcircle(p1[i],p1[j],p1[k],r);if (r==-1){calc(p1[i],p1[j]);calc(p1[i],p1[k]);calc(p1[j],p1[k]);continue;}if (r!=-1){bool can=true;for (l=1;l<=cnt1;l++)if ((p1[l].x-p.x)*(p1[l].x-p.x)+(p1[l].y-p.y)*(p1[l].y-p.y)-r*r>eps){can=false;break;}if (!can) continue;for (l=1;l<=cnt2;l++)if (r*r-(p2[l].x-p.x)*(p2[l].x-p.x)-(p2[l].y-p.y)*(p2[l].y-p.y)>eps){can=false;break;}if (can){puts("No");return 0;}}}puts("Yes");return 0;
}

Problem E

Problem F

其实这题就是预处理+判断

总状态数不超过3^9个

对于题目中所给的4张表,我们搞出所有的状态

然后暴力判断即可。

#include <bits/stdc++.h>using namespace std;#define rep(i, a, b) for (int i(a); i <= (b); ++i)
#define dec(i, a, b)    for (int i(a); i >= (b); --i)   typedef long long LL;const int N = 2e4 + 10;
const char* ch = " FUT";int an[6][6], oo[6][6], im[6][6], eq[6][6];
int mul[6][6];
int f[N][4][4];
int cnt;
int c[6][6];
int ct;
int T;set <int> mp;void init(){int s = 1;rep(i, 1, 3){rep(j, 1, 3){mul[i][j] = s;s *= 10;}}
}inline int get(int cnt){int ret = 0;rep(i, 1, 3) rep(j, 1, 3) ret += f[cnt][i][j] * mul[i][j];return ret;
}inline void work(int cnt){int h = get(cnt);mp.insert(h);
}inline void output(int cnt){dec(i, 3, 1) dec(j, 3, 1) printf("%d", f[cnt][i][j]); putchar(10);
}inline void out(){dec(i, 3, 1) dec(j, 3, 1) printf("%d", c[i][j]); putchar(10);
}inline void check(){int ret = 0;rep(i, 1, 3) rep(j, 1, 3) ret += c[i][j] * mul[i][j];if (mp.count(ret)) return;
//  out();mp.insert(ret);++cnt;rep(i, 1, 3) rep(j, 1, 3) f[cnt][i][j] = c[i][j];
}void judge(){int ret = 0;rep(i, 1, 3) rep(j, 1, 3) ret += c[i][j] * mul[i][j];if (mp.count(ret)) puts("definable");else puts("undefinable");}int main(){freopen("1.txt", "r", stdin);freopen("2.txt", "w", stdout);init();rep(i, 1, 3) rep(j, 1, 3){an[i][j] = min(i, j);oo[i][j] = max(i, j);eq[i][j] = (i == j) ? 3 : 1;}im[1][1] = im[1][2] = im[1][3] = 3;im[2][1] = 2; im[2][2] = im[2][3] = 3;im[3][1] = 1; im[3][2] = 2; im[3][3] = 3;++cnt; rep(i, 1, 3) rep(j, 1, 3) f[cnt][i][j] = im[i][j];  work(cnt);++cnt; rep(i, 1, 3) rep(j, 1, 3) f[cnt][i][j] = an[i][j];  work(cnt);++cnt; rep(i, 1, 3) rep(j, 1, 3) f[cnt][i][j] = oo[i][j];  work(cnt);++cnt; rep(i, 1, 3) rep(j, 1, 3) f[cnt][i][j] = eq[i][j];  work(cnt);rep(op, 1, 10){ct = cnt;rep(k, 1, ct){rep(l, 1, 4){rep(i, 1, 3) rep(j, 1, 3) c[i][j] = f[k][i][j];rep(i, 1, 3) rep(j, 1, 3){c[i][j] = f[l][f[k][i][j]][i];check();c[i][j] = f[l][f[k][i][j]][j];check();rep(i, 1, 3) rep(j, 1, 3) c[i][j] = f[k][i][j];}}}//    printf("%d\n", cnt);}//   printf("%d\n", cnt);scanf("%d", &T);while (T--){rep(i, 1, 3){rep(j, 1, 3){char ch[2];scanf("%s", ch);if (ch[0] == 'F') c[i][j] = 1;if (ch[0] == 'U') c[i][j] = 2;if (ch[0] == 'T') c[i][j] = 3;}}judge();}return 0;
}

Problem G

Problem H

Problem I  Intuidiff II

这题目描述真是绕得可以

其实题意就是按给出的顺序选出若干个不相交并且左端点递增的区间。

区间的价值是这个区间的长度+1

然后就变成水题了。

#include <bits/stdc++.h>using namespace std;#define rep(i, a, b) for (int i(a); i <= (b); ++i)
#define dec(i, a, b)    for (int i(a); i >= (b); --i)
#define MP      make_pair
#define fi      first
#define se      secondtypedef long long LL;const int N = 2e5 + 10;struct node{int x, y;LL val;friend bool operator < (const node &a, const node &b){return a.x < b.x;}
}  d[N];int a[N], b[N];
int n;
int cnt = 0;
int tt;LL c[N];
LL f[N];void update(int x, LL val){for (; x <= N - 2; x += x & -x) c[x] = max(c[x], val);
}LL query(int x){LL ret = 0;for (; x; x -= x & -x) ret = max(ret, c[x]);return ret;
}int main(){scanf("%d", &n);rep(i, 1, n * 2) scanf("%d", a + i), b[i] = a[i];rep(i, 1, n) d[i].val = 0ll + a[i * 2] - a[i * 2 - 1] + 1;sort(b + 1, b + 2 * n + 1);cnt = unique(b + 1, b + 2 * n + 1) - b - 1;rep(i, 1, n * 2) a[i] = lower_bound(b + 1, b + cnt + 1, a[i]) - b;rep(i, 1, n){++tt;d[i].x = a[tt];++tt;d[i].y = a[tt];}rep(i, 1, n){f[i] = query(d[i].x - 1) + d[i].val;update(d[i].y, f[i]);}LL ans = 0;rep(i, 1, N - 2) ans = max(ans, f[i]);printf("%lld\n", ans);return 0;
}

转载于:https://www.cnblogs.com/cxhscst2/p/7635858.html

2016-2017 ACM-ICPC, South Pacific Regional Contest (SPPC 16)相关推荐

  1. 2017 ACM ICPC Asia Shenyang Regional Contest 题解(10 / 13)【每日亿题2 / 16】

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 目录 A.(2017 ICPC shenyang I)Little Boxes B.(2017 ICP ...

  2. 2016 ACM / ICPC Asia dalian Regional Contest 题解(11 / 11)【每日亿题2021 / 2 / 17】

    整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 目录 A .(2017 ACM ICPC dalian H)To begin or not to be ...

  3. 2017 ACM ICPC Asia Regional - Daejeon

    2017 ACM ICPC Asia Regional - Daejeon Problem A Broadcast Stations 题目描述:给出一棵树,每一个点有一个辐射距离\(p_i\)(待确定 ...

  4. The 2019 ICPC Asia Shanghai Regional Contest

    The 2019 ICPC Asia Shanghai Regional Contest 题号 题目 知识点 A Mr. Panda and Dominoes B Prefix Code C Maze ...

  5. 2018 ICPC Asia Jakarta Regional Contest

    2018 ICPC Asia Jakarta Regional Contest 题号 题目 知识点 难度 A Edit Distance B Rotating Gear C Smart Thief D ...

  6. 2021 ICPC Southeastern Europe Regional Contest Werewolves(树上背包)

    2021 ICPC Southeastern Europe Regional Contest Werewolves(树上背包) 链接 题意:给出一个n个节点的树(n≤3000n\le3000n≤300 ...

  7. 【题目记录】——The 2021 ICPC Asia Jinan Regional Contest

    文章目录 C Optimal Strategy 组合数 H Game Coin K Search For Mafuyu 欧拉序列 题目集地址 The 2021 ICPC Asia Jinan Regi ...

  8. ICPC Central Russia Regional Contest (CRRC 19)

    ICPC Central Russia Regional Contest (CRRC 19) 文章目录 ICPC Central Russia Regional Contest (CRRC 19) A ...

  9. 2021 ICPC Southeastern Europe Regional Contest(更新至六题)

    2021 ICPC Southeastern Europe Regional Contest A题签到 A. King of String Comparison 题意:给两个字符串,找出有多少对(l, ...

  10. 2019-2020 ICPC Asia Xuzhou Regional Contest【徐州现场赛】

    题目: 209-2020 ICPC Asia Xuzhou Regional Onsite Contest E. Multiply 题意: 找到最大的 i 使得 z*x^i 是 y! 的因子 分析: ...

最新文章

  1. 转:C#读取Excel文件 (2009年9月28日)
  2. DEDECMS整合DISCUZ的方法
  3. (转)Spring AOP的底层实现技术
  4. java测试时找不到类,我在class文件运行不了测试文件,提示找junit4找不到任何的测试项目...
  5. Oracle入门(五B)之desc命令
  6. java类中声明log对象_用于Android环境,java环境的log打印,可打印任何类型数据
  7. 花生壳:域名诊断—客户端离线
  8. 使用腾讯位置服务 JavaScript API GL 打造自己的 3D 地图
  9. 远程真机测试平台,公用远程真机平台,云真机使用方法
  10. 输入法的TSF框架(Text Service Framework)简介
  11. HTML5字体设置重影,Word怎么设置字体重影
  12. 【HTML505】HTML基础05_区块_布局
  13. Linux系统查看有几块硬盘
  14. 牛人林达华推荐有关机器学习的数学书籍
  15. 如何制作渐变色二维码
  16. 启用数据空间:让VirtualBox虚拟机中的Ubuntu 10.10和XP主机互通有无
  17. python图像拉伸
  18. web前端期末大作业 html+css古诗词主题网页设计
  19. mybatis防止sql注入原理
  20. thinkpad笔记本键盘有些按键连按会嘟嘟响

热门文章

  1. 初学者学习哪种编程语言比较适合呢?
  2. TP5+阿里云OSS上传文件第三节,实现淘宝上传商品图片
  3. 大部头出版物排版软件
  4. word排版遇到的问题
  5. 屁孩君儿子讲解 2022 【例4.7】最小n值
  6. ICTCLAS汉语词性标注集+中文字体对应的文件名+ 常用字体、颜色、线性、标记
  7. Ubuntu更新显卡驱动与升级cuda版本“采坑“小记
  8. 【吹水阁】为什么微信红包单次上限200,不限制次数?——微信红包、转账支付宝转账
  9. Linux 配置网络桥接模式
  10. php 修改图像大小,如何改变图片大小