博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
2016-2017 ACM-ICPC Southeastern European Regional Programming Contest (SEERC 2016)
阅读量:4512 次
发布时间:2019-06-08

本文共 6526 字,大约阅读时间需要 21 分钟。

题目链接 

Solved  6/11

Penalty 1652

Problem A

Problem B

Problem C

Problem D

Problem E

Problem F

预处理出一个pre数组

pre[i]表示i位字母数以内用掉多少个字母

然后就可以算出要计算的位置是第多少个字母数

最后就是转成26进制了

注意是没有0有26的26进制

1 #include
2 #include
3 #include
4 #include
5 #include
6 #include
7 #include
8 #include
9 #include
10 #include
11 #include
12 using namespace std;13 int n;14 int siz[11],pre[11],ans[11];15 int main()16 {17 //freopen("F.in","r",stdin);18 siz[1]=26;19 siz[2]=26*26+26;20 siz[3]=26*26*26+26*26+26;21 siz[4]=26*26*26*26+26*26*26+26*26+26;22 siz[5]=siz[4]+26*26*26*26*26;23 siz[6]=siz[5]+26*26*26*26*26*26;24 pre[1]=siz[1];25 pre[2]=pre[1]+(siz[2]-siz[1])*2;26 pre[3]=pre[2]+(siz[3]-siz[2])*3;27 pre[4]=pre[3]+(siz[4]-siz[3])*4;28 pre[5]=pre[4]+(siz[5]-siz[4])*5;29 pre[6]=pre[5]+(siz[6]-siz[5])*6;30 while (~scanf("%d",&n))31 {32 n++;33 int i;34 for (i=6;i>=0;i--)35 if (n>pre[i]) break;36 int pos=i;37 n=n-pre[pos];38 int nxt=n/(pos+1);39 int rest=n%(pos+1);40 if (rest!=0) nxt++;41 else rest=pos+1;42 n=siz[pos]+nxt;43 memset(ans,0,sizeof(ans));44 int cnt=pos+1;45 while (cnt--)46 {47 ans[cnt+1]+=n%26;48 if (ans[cnt+1]==0)49 {50 ans[cnt+1]=26;51 ans[cnt]--;52 }53 n=n/26;54 }55 printf("%c\n",'A'+(ans[rest]-1)); 56 }57 return 0;58 }
View Code

 

Problem G

Problem H

可以发现一定可以把所有的点连起来

因此可以不断的建立凸包

然后用一条边把外面的大凸包和里面的小凸包连起来

为了确保连成螺旋形

在建立里面的小凸包时将上一个大凸包最后一个点也加进去

然后依次连接即可

1 #include
2 #include
3 #include
4 #include
5 #include
6 #include
7 #include
8 #include
9 #include
10 #include
11 #include
12 using namespace std; 13 #define y1 khjk 14 #define y2 kjkj 15 const double pi=acos(-1.0); 16 struct point 17 { 18 double x,y; 19 int id; 20 point(){} 21 point(double _x,double _y):x(_x),y(_y) 22 {} 23 point operator -(const point &b) const 24 { 25 return point(x-b.x,y-b.y); 26 } 27 double operator *(const point &b) const 28 { 29 return x*b.x+y*b.y; 30 } 31 double operator ^(const point &b) const 32 { 33 return x*b.y-y*b.x; 34 } 35 bool operator <(const point &b) const 36 { 37 return y
0; 53 } 54 55 int convex(int n) 56 { 57 int i, len, top = 2; 58 //cout<<"hhhHH"<
1&& cross(s[top], s[top - 1],p[i])>0) top--; 67 s[++top] = p[i]; 68 //cout<
<<" "<
<
= 1; i--) 74 { 75 while(top!=len && cross(s[top], s[top - 1],p[i])>0) top--; 76 s[++top] = p[i]; 77 //cout<
<<" "<
<
View Code

 

Problem I打表发现ans <= 9

考虑BFS

不必把所有的状态都存进去

只要存能取的最大数的前面70个即可

1 #include
2 #include
3 #include
4 #include
5 #include
6 #include
7 #include
8 #include
9 #include
10 #include
11 #include
12 using namespace std;13 struct ss14 {15 int x,fa,y;16 };17 ss q[10000100];18 int h,t,n;19 bool b[44777445];20 int ans[110];21 inline bool cmp(int x,int y)22 {23 return x>y;24 }25 void push(int x,int y)26 {27 if (b[x]) return;28 b[x]=true;29 t++;30 q[t].fa=h;31 q[t].x=x;32 q[t].y=y;33 if (x==n)34 {35 int i=0,k=t;36 while (k!=0)37 {38 i++;39 ans[i]=q[k].y;40 k=q[k].fa;41 }42 printf("%d\n",i-1);43 sort(ans+1,ans+i+1,cmp);44 int j;45 for (j=1;j
>1;69 if (mid*mid*mid>rest)70 r=mid-1;71 else l=mid+1;72 }73 int p=l-1;74 for (i=p;i>=max(1,p-70);i--)75 push(x+i*i*i,i);76 }77 return 0;78 }
View Code

 

Problem J

Problem K

考虑字符串Hash

枚举两个断点,然后分成三段,总共有6个不同的排列。

对于每一段用预处理的Hash,O(1)判断即可。

有解就退出

 

#include 
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;}

 

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

你可能感兴趣的文章
java输出重定向
查看>>
load data with matlab
查看>>
ctypes调用dll的参数问题
查看>>
微信支付接口的调用(转)
查看>>
XSS攻击
查看>>
浅谈Sql各种join的用法
查看>>
Durid数据库连接池配置(不使用框架)
查看>>
BarCode128B字符转换函数(PB,SQL)
查看>>
watir学习资料
查看>>
Jmeter属性和变量
查看>>
java并发编程:并发容器之CopyOnWriteArrayList(转)
查看>>
python基础——面向对象进阶下
查看>>
Linux vi 命令详解
查看>>
本地如何搭建IPv6环境测试你的APP
查看>>
oracle、mysql新增字段,字段存在则不处理
查看>>
C++ NULL与nullptr的区别
查看>>
Discretized Streams, 离散化的流数据处理
查看>>
Spark源码分析 – SchedulerBackend
查看>>
黑马程序员 Java输入\输出
查看>>
python字符串处理
查看>>