http://hihocoder.com/problemset/problem/

#1870 : Jin Yong’s Wukong Ranking List

我是每加1个点就dfs判断1次。

正解是拓扑排序。。。

 #include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <vector>
#include <bitset>
#include <algorithm>
#include <iostream>
using namespace std;
const int maxn=; bool vis[maxn];
char str[maxn][maxn],a[maxn],b[maxn],result1[maxn],result2[maxn];
vector<int>e[maxn];
int r; void dfs(int d)
{
vector<int>::iterator j;
vis[d]=;
for (j=e[d].begin();j!=e[d].end();j++)
if (!vis[*j])
dfs(*j);
else
{
r=;
return;
}
} int main()
{
int n,i,j,k,g;
while (~scanf("%d",&n))
{
for (i=;i<=*n;i++)
e[i].clear();
g=;
r=;
for (i=;i<=n;i++)
{
scanf("%s%s",a,b);
for (j=;j<=g;j++)
if (strcmp(str[j],a)==)
break;
if (j==g+)
{
g++;
strcpy(str[g],a);
} for (k=;k<=g;k++)
if (strcmp(str[k],b)==)
break;
if (k==g+)
{
g++;
strcpy(str[g],b);
} e[j].push_back(k); memset(vis,,sizeof(vis));
if (r==)
{
dfs(k);
if (r==)
{
strcpy(result1,a);
strcpy(result2,b);
}
}
} if (r==)
printf("0\n");
else
printf("%s %s\n",result1,result2);
}
return ;
}

#1871 : Heshen's Account Book

把所有内容放入字符串里,再判断。

挺多细节要考虑的,代码下方有自己编的若干数据。

 #include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <vector>
#include <bitset>
#include <algorithm>
#include <iostream>
using namespace std;
const int maxn=2e5;
const int maxsinlen=;
const int maxlen=1e3+;
const int maxtotallen=3e5;
const int maxline=2e2+; char num[maxn][maxsinlen];
char str[maxtotallen],s[maxlen],c;
int gx[maxline]; int main()
{
int g=,len,line=,ind=,pos=,i,j,k;
bool vis=;
strcpy(str,"");
while (gets(s))
{
strcat(str,s);
strcat(str,"\n");
}
len=strlen(str); for (i=;i<len;i++)
{
if (str[i]=='\n')
{
line++;
if (i== || str[i-]<'' || str[i-]>'' || str[i+]<'' || str[i+]>'')
{
if (vis && i>ind)
{
// strncpy(num[g++],str+ind,i-ind);
///delete ' ','\n'
k=;
for (j=ind;j<i;j++)
if (str[j]>='' && str[j]<='')
num[g][k++]=str[j];
num[g][k]=;
if (!(k> && num[g][]==''))
{
g++;
gx[pos]++;
}
}
vis=;
ind=i+;
pos=line;
}
}
else if (str[i]==' ')
{
if (vis && i>ind)
{
// strncpy(num[g++],str+ind,i-ind);
///delete ' ','\n'
k=;
for (j=ind;j<i;j++)
if (str[j]>='' && str[j]<='')
num[g][k++]=str[j];
num[g][k]=;
if (!(k> && num[g][]==''))
{
g++;
gx[pos]++;
}
}
vis=;
ind=i+;
pos=line;
}
else
{
if (str[i]<'' || str[i]>'')
vis=;
}
} if (g>=)
printf("%s",num[]);
for (i=;i<g;i++)
printf(" %s",num[i]);
printf("\n"); for (i=;i<line;i++)
printf("%d\n",gx[i]);
return ;
}
/**
12
34
56
78
900 --- 003
004
005
1 006 a ---
''' 23 123
123 123 adssa q3qe
qw 1
qw123
12 ''' --- 1234
123 --- 1234
12 34 --- 1 2 3 as 4 --- 12
3
4
5a --- 00 --- 0 --- 0
12 --- 0
12asdb --- '''
0
a
0 0 0 0 12 0 01 100 10 01 0
0 ''' **/

#1873 : Frog and Portal

重现赛时,看错题了,难受。

告诫自己:比赛时,一定要认真读题,认真分析数据!

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAr0AAAFaCAYAAAATjeV/AAAQ60lEQVR4nO3diZIixxmFUbVi3v+V225LWAxiKahc/rx5ToQiJHumuyBr+SpJ4Ov7v/4AAIBgf87eAAAA6E30AgAQT/QCABBP9AIAEE/0AgAQT/QCABBP9AIAEE/0AgAQT/QCABBP9AIAEE/0AgAQT/QCABBP9AIAEE/0AgAQT/QCABBP9AIAEE/0AgAQT/QCABBP9AIAEE/0AgAQT/QCABBP9AIAEE/0AgAQT/Q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QvAADxRC8AAPFELwAA8UQvAADxRC8AAPFELwAA8UQvAADxRC8AAPFELwAA8UQvAADxRC8AAPFELwAA8f4DstuWDjIZmlYAAAAASUVORK5CYII=" alt="" />

 #include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <vector>
#include <bitset>
#include <algorithm>
#include <iostream>
using namespace std;
#define ll long long
const int maxn=1e3+; struct node
{
int x,y;
}f[]; int shu[],w; void cal(ll n)
{
if (n==)
w=;
else
{
cal(n>>);
shu[++w]=n & ;
}
} int main()
{
ll n;
int g,i,j,k;
while (~scanf("%lld",&n))
{
w=;
cal(n); g=;
j=;
k=; for (i=;i<=w;i++)
{
///(k+1)->(k+2)
f[++g]={k+,k+};
if (shu[i])
{
f[++g]={j,k+};
j+=;
}
k+=;
}
f[++g]={k,};
f[++g]={j,};
f[++g]={j+,j+};
if (n==)
f[++g]={,}; printf("%d\n",g);
for (i=;i<=g;i++)
printf("%d %d\n",f[i].x,f[i].y);
}
return ;
}
/*
0
1
2
3
4 4294967296
4294967295
4294967294 */

#1878 : Palindromes

找规律。

Java TLE了,难受!

关于字符串的处理,以后别用Java写。。。

 #include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <vector>
#include <bitset>
#include <algorithm>
#include <iostream>
using namespace std;
const int maxn=1e6+; int shu[maxn],ori[maxn];
char str[maxn]; int main()
{
int t,len,i;
scanf("%d",&t);
while (t--)
{
scanf("%s",str);
len=strlen(str);
for (i=;i<=len;i++)
shu[i]=str[len-i]-;
if (str[]>'')
{
///odd
for (i=;i<=len-;i++)
ori[i]=;
ori[len]=; for (i=;i<=len;i++)
{
shu[i]-=ori[i];
if (shu[i]<)
{
shu[i]+=;
shu[i+]--;
}
} printf("%c",shu[len]++);
for (i=len-;i>=;i--)
printf("%c",shu[i]+);
if (len>)
{
for (i=;i<=len-;i++)
printf("%c",shu[i]+);
printf("%c",shu[len]++);
}
printf("\n");
}
else if (len==)
printf("0\n");
else if (str[]=='')
{
///odd
for (i=;i<=len-;i++)
ori[i]=;
ori[len-]=; for (i=;i<=len;i++)
{
shu[i]-=ori[i];
if (shu[i]<)
{
shu[i]+=;
shu[i+]--;
}
} printf("%c",shu[len-]++);
for (i=len-;i>=;i--)
printf("%c",shu[i]+);
if (len->)
{
for (i=;i<=len-;i++)
printf("%c",shu[i]+);
printf("%c",shu[len-]++);
}
printf("\n");
}
else
{
///even
for (i=;i<=len-;i++)
ori[i]=;
ori[len-]=;
ori[len]=; for (i=;i<=len;i++)
{
shu[i]-=ori[i];
if (shu[i]<)
{
shu[i]+=;
shu[i+]--;
}
} printf("%c",shu[len-]++);
for (i=len-;i>=;i--)
printf("%c",shu[i]+);
for (i=;i<=len-;i++)
printf("%c",shu[i]+);
printf("%c",shu[len-]++);
printf("\n");
}
}
return ;
}

#1877 : Approximate Matching

得到所有与串S相似(相等)的串,组成一颗树,AC自动机,预处理每个节点遇到'0','1'到达的节点。

统计每个点在某一个位置出现的次数,每次每个点遇到'0','1',到达新的节点。

当到达叶子节点(某一个串的终止位置)时,总结果加上 该点的出现次数*2^k(k为还没确定的位置数目),同时,该节点的出现次数设置为0(以后再不出现)。

  1 #include <bits/stdc++.h>
2 using namespace std;
3 #define ll long long
4 #define minv 1e-6
5 #define inf 1e9
6 #define pi 3.1415926536
7 #define nl 2.7182818284
8 const ll mod=1e9+7;//998244353
9 const int maxn=1e5+10;
10
11 ///at most 40 strings, each string contain 40 characters
12
13 struct node
14 {
15 int c,en;
16 ll v[2];
17 node *pre;
18 node *next[2];
19 node *fail;
20 node *num[2];
21 };
22
23 ll er[50];
24 char str[50];
25 queue<node*> q;
26
27 int main()
28 {
29 node *tr,*pos,*be,*p,*d;
30 int n,m,x,y,t,i,j,k,c;
31 ll result;
32 er[0]=1;
33 for (i=1;i<=40;i++)
34 er[i]=er[i-1]<<1;
35
36 scanf("%d",&t);
37 while (t--)
38 {
39 scanf("%d%d",&n,&m);
40 scanf("%s",str);
41 if (n>m)
42 {
43 printf("0\n");
44 continue;
45 }
46 tr=(node*) malloc (sizeof(node));
47 for (i=0;i<2;i++)
48 tr->next[i]=NULL;
49 tr->en=0,tr->v[0]=0,tr->v[1]=0;
50
51 for (i=0;i<=n;i++)
52 {
53 if (i!=n)
54 str[i]=(str[i]=='0')?'1':'0';
55
56 pos=tr;
57 for (j=0;j<n;j++)
58 {
59 c=str[j]-48;
60 if (pos->next[c])
61 pos=pos->next[c];
62 else
63 {
64 p=(node*) malloc (sizeof(node));
65 for (k=0;k<2;k++)
66 p->next[k]=NULL;
67 p->en=0,p->v[0]=0,p->v[1]=0;
68 p->c=c;
69
70 pos->next[c]=p;
71 p->pre=pos;
72 pos=p;
73 }
74 }
75 pos->en=1;
76
77 if (i!=n)
78 str[i]=(str[i]=='0')?'1':'0';
79 }
80
81 be=(node*) malloc (sizeof(node));
82 for (i=0;i<2;i++)
83 be->next[i]=tr;
84 tr->pre=be;
85 tr->num[0]=tr,tr->num[1]=tr;///???
86
87 ///长度相等,不用不停fail判断是否存在拥有结尾标志的点
88 q.push(tr);
89 while (!q.empty())
90 {
91 d=q.front();
92 q.pop();
93 if (d==tr)
94 d->fail=be;
95 else
96 {
97 pos=d->pre->fail;
98 c=d->c;
99 while (pos->next[c]==NULL)
100 pos=pos->fail;
101 d->fail=pos->next[c];
102
103 for (j=0;j<2;j++)
104 if (d->fail->next[j])
105 d->num[j]=d->fail->next[j];
106 else
107 d->num[j]=d->fail->num[j];
108 }
109 for (j=0;j<2;j++)
110 if (d->next[j])
111 q.push(d->next[j]);
112 }
113
114 result=0;
115 x=0,y=1;
116 tr->v[0]=1;
117 for (i=1;i<=m;i++)
118 {
119 q.push(tr);
120 while (!q.empty())
121 {
122 d=q.front();
123 for (j=0;j<2;j++)
124 if (d->next[j])
125 d->next[j]->v[y]+=d->v[x];
126 else
127 d->num[j]->v[y]+=d->v[x];
128 q.pop();
129 for (j=0;j<2;j++)
130 if (d->next[j])
131 q.push(d->next[j]);
132 }
133
134 q.push(tr);
135 while (!q.empty())
136 {
137 d=q.front();
138 // printf("%d ",d->v[y]);
139 d->v[x]=0;
140 if (d->en==1)
141 {
142 result+=d->v[y]*er[m-i];
143 d->v[y]=0;
144 }
145 q.pop();
146 for (j=0;j<2;j++)
147 if (d->next[j])
148 q.push(d->next[j]);
149 }
150 // printf("\n");
151
152 x=x^1,y=y^1;
153 }
154 printf("%lld\n",result);
155 }
156 return 0;
157 }

The 2018 ACM-ICPC Asia Beijing Regional Contest的更多相关文章

  1. 2018 ACM-ICPC Asia Beijing Regional Contest (部分题解)

    摘要 本文主要给出了2018 ACM-ICPC Asia Beijing Regional Contest的部分题解,意即熟悉区域赛题型,保持比赛感觉. Jin Yong’s Wukong Ranki ...

  2. ACM-ICPC Asia Beijing Regional Contest 2018 Reproduction hihocoder1870~1879

    ACM-ICPC Asia Beijing Regional Contest 2018 Reproduction hihocoder1870~1879 A 签到,dfs 或者 floyd 都行. #i ...

  3. 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 ...

  4. 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 ...

  5. hihoCoder #1871 : Heshen's Account Book-字符串暴力模拟 自闭(getline()函数) (ACM-ICPC Asia Beijing Regional Contest 2018 Reproduction B) 2018 ICPC 北京区域赛现场赛B

    P2 : Heshen's Account Book Time Limit:1000ms Case Time Limit:1000ms Memory Limit:512MB Description H ...

  6. hihoCoder #1870 : Jin Yong’s Wukong Ranking List-闭包传递(递归) (ACM-ICPC Asia Beijing Regional Contest 2018 Reproduction A) 2018 ICPC 北京区域赛现场赛A

    P1 : Jin Yong’s Wukong Ranking List Time Limit:1000ms Case Time Limit:1000ms Memory Limit:512MB Desc ...

  7. 2018-2019, ICPC, Asia Yokohama Regional Contest 2018 K

    传送门:https://codeforces.com/gym/102082/attachments 题解: 代码: /** * ┏┓ ┏┓ * ┏┛┗━━━━━━━┛┗━━━┓ * ┃ ┃ * ┃ ━ ...

  8. 2018 ICPC Asia Jakarta Regional Contest

    题目传送门 题号 A B C D E F G H I J K L 状态 Ο . . Ο . . Ø Ø Ø Ø . Ο Ο:当场 Ø:已补 .  :  待补 A. Edit Distance Thin ...

  9. Gym - 101981K The 2018 ICPC Asia Nanjing Regional Contest K.Kangaroo Puzzle 暴力或随机

    题面 题意:给你1个20*20的格子图,有的是障碍有的是怪,你可以每次指定上下左右的方向,然后所有怪都会向那个方向走, 如果2个怪撞上了,就融合在一起,让你给不超过5w步,让所有怪都融合 题解:我们可 ...

随机推荐

  1. Lodop如何打印直线

    Lodop打印设计提供了可视化设计,生成代码的方便,在打印设计界面上,选择添加打印项的时候,可以看到没有添加直线选项,可添加斜线,然后把添加的斜线调整成直线:线宽=高 -----水平直线线宽=宽--- ...

  2. JQ和JS获取元素

    <ul>   <li>John</li> <li>Karl</li> <li>Brandon</li> </u ...

  3. React 学习(三) ---- state 和 事件处理函数

    在上两节中,我们讲述了props, 组件使用props进行渲染,但是这是一次性的, props渲染完成之后就不做任何事情了,但是现实中却不是这样的,当我们点击购物车上的加减按钮时,数量会自动加1或减1 ...

  4. Redis之父表示ARM服务器没戏!

    ARM表示Neoverse N1平台和E1 CPU即将发布,Neoverse N1和E1采用7nm制程,并且为服务器和通信设备增加重要提升,拥有高可扩展性.高处理量以及高性能,将分别在2020年和20 ...

  5. memcached安装报错 error while loading shared libraries: libevent-2.0.so.5: cannot open shared object file: No such file or directory解决

    我是从其他服务器scp来的memcached(~~~整个文件夹的那种,windows用多了的后遗症) 在准备运行 ./memcached -d -u root -l localhost -m 800 ...

  6. Linux服务器下安装vmware虚拟机

    安装包 1.VMware 14 https://dl-sh-ctc-2.pchome.net/08/b7/VMware-Workstation-Full-14.1.3-9474260.x86_64.b ...

  7. 关于2-sat的建图方法及解决方案

    转载增减: https://blog.csdn.net/qq_24451605/article/details/47126143 https://blog.csdn.net/u012915516/ar ...

  8. Day24-ModelForm操作及验证

    Day23内容回顾--缺失,遗憾成狗. 一:Model(2个功能) -数据库操作: -验证,只有一个clean方法可以作为钩子. 二:Form(专门来做验证的)--------根据form里面写的类, ...

  9. php+redis配置

    系统环境: win10+phpstudy+lamp 安装扩展 php5.6.4 =>下载地址:http://windows.php.net/downloads/pecl/releases/red ...

  10. 正睿 2019 省选附加赛 Day10

    A 核心就是一个公式 \[\sum_{i = 0}^{k} S(k, i) \tbinom{x}{i} i\] S是第二类斯特林数 递推公式 \(S_2(n,k)=S_2(n−1,k−1)+kS_2( ...