2016-2017 ACM-ICPC, South Pacific Regional Contest (SPPC 16)
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)
{
return
max(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;
else
return 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 second typedef 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;
}
2016-2017 ACM-ICPC, South Pacific Regional Contest (SPPC 16)的更多相关文章
- ACM ICPC Central Europe Regional Contest 2013 Jagiellonian University Kraków
ACM ICPC Central Europe Regional Contest 2013 Jagiellonian University Kraków Problem A: Rubik’s Rect ...
- 2017 ACM - ICPC Asia Ho Chi Minh City Regional Contest
2017 ACM - ICPC Asia Ho Chi Minh City Regional Contest A - Arranging Wine 题目描述:有\(R\)个红箱和\(W\)个白箱,将这 ...
- 2017 ACM/ICPC Asia Regional Shenyang Online spfa+最长路
transaction transaction transaction Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 132768/1 ...
- 2017 ACM ICPC Asia Regional - Daejeon
2017 ACM ICPC Asia Regional - Daejeon Problem A Broadcast Stations 题目描述:给出一棵树,每一个点有一个辐射距离\(p_i\)(待确定 ...
- 2017 ACM/ICPC Asia Regional Qingdao Online
Apple Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submi ...
- 2017 ACM/ICPC Shenyang Online SPFA+无向图最长路
transaction transaction transaction Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 132768/1 ...
- 2019-2020 ICPC, Asia Jakarta Regional Contest (Online Mirror, ICPC Rules, Teams Preferred)
2019-2020 ICPC, Asia Jakarta Regional Contest (Online Mirror, ICPC Rules, Teams Preferred) easy: ACE ...
- HDU - 6215 2017 ACM/ICPC Asia Regional Qingdao Online J - Brute Force Sorting
Brute Force Sorting Time Limit: 1 Sec Memory Limit: 128 MB 题目连接 http://acm.hdu.edu.cn/showproblem.p ...
- 2017 ACM/ICPC Asia Regional Shenyang Online(部分题解)
HDU 6197 array array array 题意 输入n和k,表示输入n个整数和可以擦除的次数k,如果至多擦除k次能是的数组中的序列是不上升或者是不下降序列,就是魔力数组,否则不是. 解题思 ...
随机推荐
- selenium +python web自动化测试环境搭建
基础框架搭建 1.安装python 2.安装selenium cmd输入pip install selenium 问题:在python中输入from selenium import webdriver ...
- JAVA基础篇—异常
五种常见异常 1.NullPointerException 空指针 2.ClassNotFoundException 指定类不存在 3.ArithmeticException运算异常 4.ArrayI ...
- poj-1979 red and black(搜索)
Time limit1000 ms Memory limit30000 kB There is a rectangular room, covered with square tiles. Each ...
- debian软raid
http://www.linuxidc.com/Linux/2013-06/86487.htm
- 在spring boot中使用webSocket组件(一)
最近在项目中使用到了spring的webSocket组件,在这里和大家分享下,如有错误,欢迎大家指正. 在这里我使用的IDE工具是Intellij idea,框架是spring boot.spring ...
- Linux学习-Linux的账号与群组
使用者识别码: UID 与 GID Linux 主机并不会直接认识 你的"帐号名称"的,他仅认识 ID 啊 (ID 就是一组号码啦). 由于计算机仅认识 0 与 1,所 以主机对于 ...
- CodeForces 570E DP Pig and Palindromes
题意:给出一个n行m列的字符矩阵,从左上角走到右下角,每次只能往右或者往下走,求一共有多少种走法能得到回文串. 分析: 可以从两头开始考虑,每次只走一样字符的格子,这样得到的两个字符串拼起来之后就是一 ...
- quarz spring boot
package com.pkfare.task.manage.config; import org.quartz.spi.TriggerFiredBundle; import org.springfr ...
- Linux中 find 常见用法示例
Linux中find常见用法示例 #find path -option [ -print ] [ -exec -ok command ] {} \; #-print 将查找到的文件输出到标准输出 #- ...
- csa Round #70
Digit Holes Time limit: 1000 msMemory limit: 256 MB When writing digits, some of them are consider ...