2016-2017 ACM-ICPC Southeastern European Regional Programming Contest (SEERC 2016)
题目链接 Codefores_Gym_101164
Solved 6/11
Penalty
Problem A
Problem B
Problem C
Problem D
Problem E
Problem F
预处理出一个pre数组
pre[i]表示i位字母数以内用掉多少个字母
然后就可以算出要计算的位置是第多少个字母数
最后就是转成26进制了
注意是没有0有26的26进制
#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 n;
int siz[],pre[],ans[];
int main()
{
//freopen("F.in","r",stdin);
siz[]=;
siz[]=*+;
siz[]=**+*+;
siz[]=***+**+*+;
siz[]=siz[]+****;
siz[]=siz[]+*****;
pre[]=siz[];
pre[]=pre[]+(siz[]-siz[])*;
pre[]=pre[]+(siz[]-siz[])*;
pre[]=pre[]+(siz[]-siz[])*;
pre[]=pre[]+(siz[]-siz[])*;
pre[]=pre[]+(siz[]-siz[])*;
while (~scanf("%d",&n))
{
n++;
int i;
for (i=;i>=;i--)
if (n>pre[i]) break;
int pos=i;
n=n-pre[pos];
int nxt=n/(pos+);
int rest=n%(pos+);
if (rest!=) nxt++;
else rest=pos+;
n=siz[pos]+nxt;
memset(ans,,sizeof(ans));
int cnt=pos+;
while (cnt--)
{
ans[cnt+]+=n%;
if (ans[cnt+]==)
{
ans[cnt+]=;
ans[cnt]--;
}
n=n/;
}
printf("%c\n",'A'+(ans[rest]-));
}
return ;
}
Problem G
Problem H
可以发现一定可以把所有的点连起来
因此可以不断的建立凸包
然后用一条边把外面的大凸包和里面的小凸包连起来
为了确保连成螺旋形
在建立里面的小凸包时将上一个大凸包最后一个点也加进去
然后依次连接即可
#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
const double pi=acos(-1.0);
struct point
{
double x,y;
int id;
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;
}
bool operator <(const point &b) const
{
return y<b.y||(y==b.y&&x<b.x);
}
};
double cross(point sp,point ep,point op)
{
//cout<< (sp.x-op.x)*(ep.y-op.y)-(sp.y-op.y)*(ep.x-op.x)<<endl;
return (sp.x-op.x)*(ep.y-op.y)-(sp.y-op.y)*(ep.x-op.x);
}
int n,L;
point p[],s[],u[],as[],w[];
int ans[],id[],nid[];
bool used[];
bool cmp(const point &a, const point &b)//逆时针排序
{
point origin=s[];
return cross(a,b,origin)> ;
} int convex(int n)
{
int i, len, top = ;
//cout<<"hhhHH"<<endl;
sort(p+, p + n+);
if(n == ) return ; s[] = p[];
if(n == ) return ; s[] = p[];
if(n == ) return ; s[] = p[]; for(int i = ; i <=n; i++)
{
while(top >&& cross(s[top], s[top - ],p[i])>) top--;
s[++top] = p[i];
//cout<<top<<" "<<id[i]<<endl;
} len = top; s[++top] = p[n - ]; for(int i = n - ; i >= ; i--)
{
while(top!=len && cross(s[top], s[top - ],p[i])>) top--;
s[++top] = p[i];
//cout<<top<<" "<<id[i]<<endl;
}
return top;
}
double dis(point a,point b)
{
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
int main()
{
int fg=;
while (~scanf("%d",&n))
{
int i;
for (i=;i<=n;i++)
{
double x,y;
scanf("%lf%lf",&x,&y);
p[i]=point(x,y);
p[i].id=i;
w[i]=p[i];
}
int rest=n;
memset(used,false,sizeof(used));
int cnt=convex(n);
cnt--;
int ct=;
//sort(s+2,s+cnt+1,cmp);
for (i=;i<=cnt;i++)
ans[++ct]=s[i].id,used[s[i].id]=true,as[ct]=s[i];
while (cnt<rest)
{
rest=;
u[rest]=as[ct];
//cout<<as[ct].id<<endl;
int id=as[ct].id;
ct--;
for (i=;i<=n;i++)
if (!used[i])
u[++rest]=w[i];
for (i=;i<=rest;i++)
p[i]=u[i];//cout<<p[i].id<<" ";
//cout<<endl;
cnt=convex(rest);
cnt--;
//sort(s+2,s+cnt+1,cmp);
for (i=;i<=cnt;i++)
if (s[i].id==id) break;
//cout<<cnt<<endl;
//for (int j=1;j<=cnt;j++)
// cout<<s[j].id<<" ";
//cout<<endl;
int now=i;
for (i=;i<=cnt;i++)
{
ans[++ct]=s[now].id;
as[ct]=s[now];
used[s[now].id]=true;
now++;
if (now==cnt+) now=;
}
}
printf("%d\n",n);
for (i=;i<n;i++)
printf("%d ",ans[i]);
printf("%d\n",ans[n]);
}
return ;
}
Problem I打表发现ans <= 9
考虑BFS
不必把所有的状态都存进去
只要存能取的最大数的前面70个即可
#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;
struct ss
{
int x,fa,y;
};
ss q[];
int h,t,n;
bool b[];
int ans[];
inline bool cmp(int x,int y)
{
return x>y;
}
void push(int x,int y)
{
if (b[x]) return;
b[x]=true;
t++;
q[t].fa=h;
q[t].x=x;
q[t].y=y;
if (x==n)
{
int i=,k=t;
while (k!=)
{
i++;
ans[i]=q[k].y;
k=q[k].fa;
}
printf("%d\n",i-);
sort(ans+,ans+i+,cmp);
int j;
for (j=;j<i-;j++)
printf("%d ",ans[j]);
printf("%d\n",ans[i-]);
exit();
}
}
int main()
{
scanf("%d",&n);
h=;
t=;
q[].fa=;
q[].x=;
q[].y=;
while (h<t)
{
h++;
int x=q[h].x;
int rest=n-x;
int i;
int l=,r=;
while (l<=r)
{
int mid=(l+r)>>;
if (mid*mid*mid>rest)
r=mid-;
else l=mid+;
}
int p=l-;
for (i=p;i>=max(,p-);i--)
push(x+i*i*i,i);
}
return ;
}
Problem J
Problem K
考虑字符串Hash
枚举两个断点,然后分成三段,总共有6个不同的排列。
对于每一段用预处理的Hash,O(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) typedef long long LL; const int N = 5010;
const LL mod = 1e9 + 7; LL base = 1e10 + 3;
LL sHash[N], sbin[N];
LL tHash[N], tbin[N];
int n;
char s[N], t[N];
LL cc[N];
int yy[N]; void sHashtable(){
sbin[0] = 1LL;
rep(i, 1, n) sbin[i] = (sbin[i - 1] * base);
rep(i, 1, n) sHash[i] = (sHash[i - 1] * base + s[i]);
} inline LL sgethash(const int &l, const int &r){
return (sHash[r] - sHash[l - 1] * sbin[r - l + 1]);
} void tHashtable(){
tbin[0] = 1LL;
rep(i, 1, n) tbin[i] = (tbin[i - 1] * base);
rep(i, 1, n) tHash[i] = (tHash[i - 1] * base + t[i]);
} inline LL tgethash(const int &l, const int &r){
return (tHash[r] - tHash[l - 1] * tbin[r - l + 1]);
} void print(int l1, int r1, int l2, int r2, int l3, int r3){
puts("YES");
rep(i, l1, r1) putchar(t[i]); putchar(10);
rep(i, l2, r2) putchar(t[i]); putchar(10);
rep(i, l3, r3) putchar(t[i]); putchar(10);
exit(0);
} int main(){ scanf("%s", s + 1);
n = strlen(s + 1); rep(i, 0, n) cc[i] = (LL)rand() * (LL)rand() * (LL)rand(); rep(i, 1, n) if (s[i] < 'a') s[i] = s[i] - 'A' + 'a';
scanf("%s", t + 1);
rep(i, 1, n) if (t[i] < 'a') t[i] = t[i] - 'A' + 'a'; sHashtable();
tHashtable(); rep(i, 1, n - 2){
dec(j, n, i + 2){ int l1 = 1, r1 = i;
int l2 = i + 1, r2 = j - 1;
int l3 = j, r3 = n; int c1 = r1 - l1 + 1;
int c2 = r2 - l2 + 1;
int c3 = r3 - l3 + 1; if (sgethash(1, c1) == tgethash(l1, r1)){
if (sgethash(c1 + 1, c1 + c2) == tgethash(l2, r2)){
if (sgethash(c1 + c2 + 1, n) == tgethash(l3, r3)){
print(l1, r1, l2, r2, l3, r3);
}
}
} swap(l2, l3);
swap(r2, r3);
swap(c2, c3);
if (sgethash(1, c1) == tgethash(l1, r1)){
if (sgethash(c1 + 1, c1 + c2) == tgethash(l2, r2)){
if (sgethash(c1 + c2 + 1, n) == tgethash(l3, r3)){
print(l1, r1, l2, r2, l3, r3);
}
}
} swap(l2, l1);
swap(r2, r1);
swap(c2, c1); if (sgethash(1, c1) == tgethash(l1, r1)){
if (sgethash(c1 + 1, c1 + c2) == tgethash(l2, r2)){
if (sgethash(c1 + c2 + 1, n) == tgethash(l3, r3)){
print(l1, r1, l2, r2, l3, r3);
}
}
} swap(l2, l3);
swap(r2, r3);
swap(c2, c3);
if (sgethash(1, c1) == tgethash(l1, r1)){
if (sgethash(c1 + 1, c1 + c2) == tgethash(l2, r2)){
if (sgethash(c1 + c2 + 1, n) == tgethash(l3, r3)){
print(l1, r1, l2, r2, l3, r3);
}
}
} swap(l2, l1);
swap(r2, r1);
swap(c2, c1); if (sgethash(1, c1) == tgethash(l1, r1)){
if (sgethash(c1 + 1, c1 + c2) == tgethash(l2, r2)){
if (sgethash(c1 + c2 + 1, n) == tgethash(l3, r3)){
print(l1, r1, l2, r2, l3, r3);
}
}
} swap(l2, l3);
swap(r2, r3);
swap(c2, c3);
if (sgethash(1, c1) == tgethash(l1, r1)){
if (sgethash(c1 + 1, c1 + c2) == tgethash(l2, r2)){
if (sgethash(c1 + c2 + 1, n) == tgethash(l3, r3)){
print(l1, r1, l2, r2, l3, r3);
}
}
}
}
} puts("NO");
return 0;
}
2016-2017 ACM-ICPC Southeastern European Regional Programming Contest (SEERC 2016)的更多相关文章
- 2017-2018 ACM-ICPC Southeastern European Regional Programming Contest (SEERC 2017)
2017-2018 ACM-ICPC Southeastern European Regional Programming Contest (SEERC 2017) 全靠 wxh的博客 补完这套.wx ...
- 2018-2019 ACM-ICPC Southeastern European Regional Programming Contest (SEERC 2018)
layout: post title: 2018-2019 ACM-ICPC Southeastern European Regional Programming Contest (SEERC 201 ...
- 2017-2018 ACM-ICPC Southeastern European Regional Programming Contest (SEERC 2017) Solution
A:Concerts 题意:给出一个串T, 一个串S,求串S中有多少个串T,可以重复,但是两个字符间的距离要满足给出的数据要求 思路:先顺序统计第一个T中的字符在S中有多少个,然后对于第二位的以及后面 ...
- Gym 2009-2010 ACM ICPC Southwestern European Regional Programming Contest (SWERC 2009) A. Trick or Treat (三分)
题意:在二维坐标轴上给你一堆点,在x轴上找一个点,使得该点到其他点的最大距离最小. 题解:随便找几个点画个图,不难发现,答案具有凹凸性,有极小值,所以我们直接三分来找即可. 代码: int n; lo ...
- 2018-2019 ACM-ICPC Southeastern European Regional Programming Contest (SEERC 2018) Solution
A. Numbers Unsolved. B. Broken Watch Solved. 题意: 一个圆盘上,有等分的n块区域,有三根指针,当三根指针分别位于两块区域的交界处时 指针的三点相连会形成一 ...
- 2016-2017 ACM-ICPC Southwestern European Regional Programming Contest (SWERC 2016) F dfs序+树状数组
Performance ReviewEmployee performance reviews are a necessary evil in any company. In a performance ...
- 2016-2017 ACM-ICPC Southwestern European Regional Programming Contest (SWERC 2016)
A. Within Arm's Reach 留坑. B. Bribing Eve 枚举经过$1$号点的所有直线,统计直线右侧的点数,旋转卡壳即可. 时间复杂度$O(n\log n)$. #includ ...
- 2016-2017 ACM-ICPC Northwestern European Regional Programming Contest (NWERC 2016)
A. Arranging Hat $f[i][j]$表示保证前$i$个数字有序,修改了$j$次时第$i$个数字的最小值. 时间复杂度$O(n^3m)$. #include <bits/stdc+ ...
- 2016-2017 ACM-ICPC Southwestern European Regional Programming Contest (SWERC 2016) B - Bribing Eve
地址:http://codeforces.com/gym/101174/attachments 题目:pdf,略 思路: 把每个人的(x1,x2)抽象成点(xi,yi). 当1号比i号排名高时有==& ...
随机推荐
- 教程笔记《JavaScript深入浅出》
一.数据类型 javascript是弱数据类型语言,不需要显式的定义类型,一共有如下六种数据类型 五种基本类型:number,string,boolean,null,undefined 一种复合类型: ...
- gulp的安装和使用
安装nodejs -> 全局安装gulp -> 项目安装gulp以及gulp插件 -> 配置gulpfile.js -> 运行任务 1.去nodejs官网安装nodejs 2. ...
- Python基础——字典(dict)
由键-值对构建的集合. 创建 dic1={} type(dic1) dic2=dict() type(dic2) 初始化 dic2={'hello':123,'world':456,'python': ...
- selenium +python web自动化测试环境搭建
基础框架搭建 1.安装python 2.安装selenium cmd输入pip install selenium 问题:在python中输入from selenium import webdriver ...
- Altium Designer入门学习笔记2:使用原创客3D元件库
请自行淘宝购买: 元件库列表(2018年11月27日): 问题一:在项目库或已安装的库中找不到? 将"原创客"提供的文件全部添加到libraries中!"原创客" ...
- QT添加自定义信号后编译出现undefined reference
QT添加自定义信号后编译出现undefined reference 这是需要重新生成qmake: build --->run qmake
- Linux学习-账号管理
新增与移除使用者: useradd, 相关配置文件, passwd, usermod, userdel 我们登入系统时会输入 (1)账号与 (2)密码,所以建立一个可用的账号同样的也需要这两个数据.那 ...
- 常用C/C++预处理指令详解
预处理是在编译之前的处理,而编译工作的任务之一就是语法检查,预处理不做语法检查.预处理命令以符号“#”开头. 常用的预处理指令包括: 宏定义:#define 文件包含:#include 条件编译:#i ...
- HDU 1827 强连通 缩点 Summer Holiday
求出强连通分量,因为强连通中只要有一个人被通知到了,所有人都能被通知到. 缩点以后形成一个DAG,找出那些入度为0的点,累加上它们的权值就是答案.一个点的权值等于SCC中权值最小的那个点. #incl ...
- 《Scrum实战》第1课【知易行难】全团课后任务汇总
1组 孟帅(班长) kecyru 2017-7-5 http://kecyru.blog.163.com/blog/static/27416617320176411513013 htt ...