2018 ACM 网络选拔赛 沈阳赛区
B. Call of Accepted
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <time.h>
#include <string>
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <vector>
#include <bitset>
#include <ext/rope>
#include <algorithm>
#include <iostream>
using namespace std;
#define ll long long
#define minv 1e-6
#define inf 1e9
#define pi 3.1415926536
#define nl 2.7182818284
const ll mod=1e9+;//
const int maxn=1e2+; /**
+ - 3
* / 2
d 1
( ) 0
**/ int xl[maxn],xr[maxn],y[maxn];
char s[maxn],z[maxn]; int main()
{
int len,i,g1,g2,a,b,c,d,sym;
while (~scanf("%s",s))
{
len=strlen(s);
g1=;
g2=;
y[]=inf;
for (i=;i<len;i++)
if (s[i]>='' && s[i]<='')
{
g1++;
xl[g1]=;
while (s[i]>='' && s[i]<='')
{
xl[g1]=xl[g1]*+s[i]-;
i++;
}
i--;
xr[g1]=xl[g1];
}
else
{
switch(s[i])
{
case '(':
sym=;
break;
case ')':
sym=;
break;
case 'd':
sym=;
break;
case '*':
sym=;
break;
case '/':
sym=;
break;
case '+':
sym=;
break;
case '-':
sym=;
break;
}
while (y[g2]<=sym || s[i]==')')
{
switch(z[g2])
{
case 'd':
///ldr l>=0,r>=1,else illegal
///正数,负数
xl[g1-]=max(,xl[g1-]);
xl[g1]=max(,xl[g1]);
xr[g1-]*=xr[g1];
break;
case '+':
xl[g1-]+=xl[g1];
xr[g1-]+=xr[g1];
break;
case '-':
xl[g1-]-=xr[g1];
xr[g1-]-=xl[g1];
break;
case '*':
a=xl[g1-]*xl[g1];
b=xl[g1-]*xr[g1];
c=xr[g1-]*xl[g1];
d=xr[g1-]*xr[g1];
xl[g1-]=min(min(a,b),min(c,d));
xr[g1-]=max(max(a,b),max(c,d));
break;
case '/':
a=xl[g1-]/xl[g1];
b=xl[g1-]/xr[g1];
c=xr[g1-]/xl[g1];
d=xr[g1-]/xr[g1];
xl[g1-]=min(min(a,b),min(c,d));
xr[g1-]=max(max(a,b),max(c,d));
break;
case '(':
break;
}
if (z[g2]=='(')
break;
g2--;
g1--;
}
if (s[i]==')')
g2--;
else
{
y[++g2]=sym;
z[g2]=s[i];
}
} while (g2!=)
{
switch(z[g2])
{
case 'd':
xr[g1-]*=xr[g1];
break;
case '+':
xl[g1-]+=xl[g1];
xr[g1-]+=xr[g1];
break;
case '-':
xl[g1-]-=xr[g1];
xr[g1-]-=xl[g1];
break;
case '*':
a=xl[g1-]*xl[g1];
b=xl[g1-]*xr[g1];
c=xr[g1-]*xl[g1];
d=xr[g1-]*xr[g1];
xl[g1-]=min(min(a,b),min(c,d));
xr[g1-]=max(max(a,b),max(c,d));
break;
case '/':
a=xl[g1-]/xl[g1];
b=xl[g1-]/xr[g1];
c=xr[g1-]/xl[g1];
d=xr[g1-]/xr[g1];
xl[g1-]=min(min(a,b),min(c,d));
xr[g1-]=max(max(a,b),max(c,d));
break;
case '(':
break;
}
g2--;
g1--;
} printf("%d %d\n",xl[],xr[]);
} return ;
}
/*
3*(2d3)
1+1d2d3d4d5+2 (2d3)*(1+3*3d4)d5 (2+(3*4+5d1d3)d2)d3 (10-30)*3d4 (10-3d4)*2d3 (10-3d4)*(10-3d4) (10-5d5)*(10-5d5) 3d(10-3d4)
3d(10-3d4)d(10-3d4)
*/
D. Made In Heaven
F. Fantastic Graph
详细题解:https://blog.csdn.net/qq_40993793/article/details/82626562
判断是否存在可行流(满足下界条件):
汇点T -> 源点S inf(如果有流,则源源不断增加)
超级源点SS -> 超级汇点TT 判断是否满流,值为点TT的入度
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <bitset>
#include <algorithm>
#include <iostream>
using namespace std;
#define ll long long
const int maxn=4e3+;
const int inf=1e9; struct node
{
int d,len;
node *next,*opp;
}*e[maxn]; int sum=,s,t;
int q[maxn],dep[maxn];
bool vis[maxn]; void add_edge(int x,int y,int len)
{
node *p1=(node*) malloc (sizeof(node));
node *p2=(node*) malloc (sizeof(node)); p1->d=y;
p1->len=len;
p1->next=e[x];
p1->opp=p2;
e[x]=p1; p2->d=x;
p2->len=;
p2->next=e[y];
p2->opp=p1;
e[y]=p2;
} bool bfs()
{
int head=,tail=,d,dd;
node *p;
memset(vis,,sizeof(vis));
vis[s]=;
dep[s]=;
q[]=s; while (head<tail)
{
head++;
d=q[head];
p=e[d];
while (p)
{
dd=p->d;
if (p->len> && !vis[dd])
{
tail++;
q[tail]=dd;
vis[dd]=;
dep[dd]=dep[d]+;
}
p=p->next;
}
}
if (vis[t])
return ;
return ;
} int dfs(int d,int add)
{
if (!add || d==t)
return add;
int totf=,f,dd;
node *p=e[d];
while (p)
{
dd=p->d;
if (dep[dd]==dep[d]+ && (f=dfs(dd,min(add,p->len)))>)
{
totf+=f;
add-=f;///зЂвт
p->len-=f;
p->opp->len+=f;
}
p=p->next;
}
return totf;
} int main()
{
int n,m,k,l,r,x,y,i,T=; while (~scanf("%d%d%d",&n,&m,&k))
{
scanf("%d%d",&l,&r);
s=n+m+,t=n+m+;
for (i=;i<=t;i++)
e[i]=NULL; for (i=;i<=n;i++)
add_edge(n+m+,i,l);
add_edge(,n+m+,l*n);
for (i=;i<=n;i++)
add_edge(,i,r-l); add_edge(n+m+,n+m+,l*m);
for (i=n+;i<=n+m;i++)
add_edge(i,n+m+,l);
for (i=n+;i<=n+m;i++)
add_edge(i,n+m+,r-l); add_edge(n+m+,,inf); while (k--)
{
scanf("%d%d",&x,&y);
add_edge(x,n+y,);
} sum=;
while (bfs())
sum+=dfs(s,inf);
printf("Case %d: ",++T);
if (sum==(n+m)*l)
printf("Yes\n");
else
printf("No\n");
}
return ;
}
G. Spare Tire
I. Lattice's basics in digital electronics
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <time.h>
#include <string>
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <vector>
#include <bitset>
#include <ext/rope>
#include <algorithm>
#include <iostream>
using namespace std;
#define ll long long
#define minv 1e-6
#define inf 1e9
#define pi 3.1415926536
#define nl 2.7182818284
const ll mod=1e9+;//
const int maxn=1e5+; int tr[];
char s1[*],s2[*],s3[*],s4[*];
char s[*]; int main()
{
int t,m,n,a,i,j,k,len,now,g,value;
scanf("%d",&t);
while (t--)
{
memset(tr,,sizeof(tr));
scanf("%d%d",&m,&n);
for (i=;i<=n;i++)
{
scanf("%d%s",&a,s);
len=strlen(s);
k=;
for (j=;j<len;j++)
k=(k<<)+s[j]-;
tr[k]=a;
} scanf("%s",s1);
len=strlen(s1);
j=;
for (i=;i<len;i++)
{
if (s1[i]>='' && s1[i]<='')
value=s1[i]-;
else if (s1[i]>='A' && s1[i]<='F')
value=s1[i]-;
else
value=s1[i]-; s2[j++]=value/+;
value%=;
s2[j++]=value/+;
value%=;
s2[j++]=value/+;
value%=;
s2[j++]=value+;
}
s2[j]='\0';
len=j; now=;
for (i=;i<len/;i++)
{
g=;
j=i*;
for (k=j;k<j+;k++)
g+=s2[k]-;
if ((g+)%==s2[k]-)
{
for (k=j;k<j+;k++)
s3[now++]=s2[k];
}
}
s3[now]='\0'; j=;
len=;
for (i=;i<now;i++)
{
j=j*+s3[i]-;
if (j>)
continue;
if (tr[j])
{
s4[len++]=tr[j];
if (len==m)
break;
j=;
}
}
s4[len]='\0';
printf("%s\n",s4);
}
return ;
}
/*
10
8 3
49 0001
50 01001
51 011
14DB24722698 2
15 9
32 0100
33 11
100 1011
101 0110
104 1010
108 00
111 100
114 0111
119 0101
908 100
100 2
65 010
66 1011
AAAAAA
*/
K. Supreme Number
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <time.h>
#include <string>
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <vector>
#include <bitset>
#include <ext/rope>
#include <algorithm>
#include <iostream>
using namespace std;
#define ll long long
#define minv 1e-6
#define inf 1e9
#define pi 3.1415926536
#define nl 2.7182818284
const ll mod=1e9+;//
const int maxn=1e5+; typedef pair<int,int> P; char str[maxn];
int g=,b,a[maxn];
int c[]={,,,,};
int shi[]; bool prime(int t)
{
int i;
for (i=;i<=sqrt(t);i++)
if (t%i==)
return ;
return ;
} void dfs(int s,int w,vector<P>v)
{
vector<P>::iterator j;
vector<P>vv;
int t,i; for (i=;i<;i++)
{ // if (shi[w]*c[i]+s==711)
// printf("z"); for (j=v.begin();j!=v.end();j++)
{
if (!prime(j->first+shi[j->second]*c[i]))
break;
} if (j==v.end())
{
t=shi[w]*c[i]+s;
vv.clear();
for (j=v.begin();j!=v.end();j++)
{
vv.push_back(make_pair(j->first,j->second));
vv.push_back(make_pair(j->first+shi[j->second]*c[i],j->second+));
}
vv.push_back(make_pair(c[i],)); // printf("%d:\n",t);
// for (j=vv.begin();j!=vv.end();j++)
// printf("%d\n",j->first); g++;
a[g]=t;
dfs(t,w+,vv);
}
}
} int main()
{
vector<P>v;
int t,T,i;
// cout<<pow(10,0)<<endl;
// cout<<pow(10,1)<<endl;
// cout<<pow(10,2)<<endl;
//
// printf("\n");
//
// printf("%f\n",pow(10,0));
// printf("%f\n",pow(10,1));
// printf("%f\n",pow(10,2));
//
// printf("\n");
//
// printf("%d\n",pow(10,0));
// printf("%d\n",pow(10,1));
// printf("%d\n",pow(10,2));
//
// printf("\n");
//
// printf("%d\n",(int)pow(10,0));
// printf("%d\n",(int)pow(10,1));
// printf("%d\n",(int)pow(10,2));
//
// printf("\n");
//
// printf("\n");
//
// printf("%f\n",log(2)/log(2));
// printf("%f\n",log(4)/log(2));
// printf("%f\n",log(8)/log(2));
// printf("%f\n",log(16)/log(2));
//
// printf("%d\n",(int)(log(2)/log(2)));
// printf("%d\n",(int)(log(4)/log(2)));
// printf("%d\n",(int)(log(8)/log(2)));
// printf("%d\n",(int)(log(16)/log(2)));
//
// printf("\n");
//
// printf("%d\n",(int)log(2)/log(2));
// printf("%d\n",(int)log(4)/log(2));
// printf("%d\n",(int)log(8)/log(2));
// printf("%d\n",(int)log(16)/log(2));
// return 0; shi[]=;
for (i=;i<=;i++)
shi[i]=shi[i-]*; v.push_back(make_pair(,));
dfs(,,v);
sort(a+,a+g+); // for (i=1;i<=g;i++)
// printf("%d ",a[i]); scanf("%d",&t);
for (T=;T<=t;T++)
{
scanf("%str",str);
if (strlen(str)>)
{
printf("Case #%d: %d\n",T,a[g]);
continue;
}
b=atoi(str);
for (i=g;i>=;i--)
if (b>=a[i])
break;
printf("Case #%d: %d\n",T,a[i]);
}
return ;
}
2018 ACM 网络选拔赛 沈阳赛区的更多相关文章
- 2018 ACM 网络选拔赛 青岛赛区
一些题目的代码被网站吞了…… Problem B. Red Black Tree http://acm.zju.edu.cn/onlinejudge/searchProblem.do?contestI ...
- 2018 ACM 网络选拔赛 北京赛区
A Saving Tang Monk II #include <bits/stdc++.h> using namespace std; ; struct node { int x,y,z, ...
- 2018 ACM 网络选拔赛 徐州赛区
A. Hard to prepare #include <cstdio> #include <cstdlib> #include <cmath> #include ...
- 2018 ACM 网络选拔赛 焦作赛区
A. Magic Mirror #include <cstdio> #include <cstdlib> #include <cmath> #include < ...
- 2018 ACM 网络选拔赛 南京赛区
A. An Olympian Math Problem #include <cstdio> #include <cstdlib> #include <cmath> ...
- ACM-ICPC 2018 沈阳赛区网络预赛 K Supreme Number(规律)
https://nanti.jisuanke.com/t/31452 题意 给出一个n (2 ≤ N ≤ 10100 ),找到最接近且小于n的一个数,这个数需要满足每位上的数字构成的集合的每个非空子集 ...
- ACM-ICPC 2018 沈阳赛区网络预赛-K:Supreme Number
Supreme Number A prime number (or a prime) is a natural number greater than 11 that cannot be formed ...
- ACM-ICPC 2018 沈阳赛区网络预赛-D:Made In Heaven(K短路+A*模板)
Made In Heaven One day in the jail, F·F invites Jolyne Kujo (JOJO in brief) to play tennis with her. ...
- 图上两点之间的第k最短路径的长度 ACM-ICPC 2018 沈阳赛区网络预赛 D. Made In Heaven
131072K One day in the jail, F·F invites Jolyne Kujo (JOJO in brief) to play tennis with her. Howe ...
随机推荐
- Mac下通过VMware Fusion安装centos虚拟机操作记录
下面介绍下利用VMware Fusion工具在Mac上安装centos虚拟机的做法:1)下载VMware Fusion工具下载地址(包括注册码):http://www.macx.cn/thread-2 ...
- python-深浅copy-18
# 赋值运算l1 = [1,2,3]l2 = l1l1.append('a')print(l1,l2) # [1, 2, 3, 'a'] [1, 2, 3, 'a'] #copyl1 = [1,2,3 ...
- Today
I'm facing the major enemy. The information. I don't know when I've been crazy about seeking informa ...
- 同步手绘板——将View的内容映射成Bitmap转图片导出
在Android中自有获取view中的cache内容,然后将内容转换成bitmap,方法名是:getDrawingCache(),返回结果为Bitmap,但是刚开始使用的时候,得到的结果都是null, ...
- github更新,发布地址,燃尽图,总结
github地址:https://github.com/Lingchaoyang 网盘发布地址:http://pan.baidu.com/s/1qXgHiyC 燃尽图: 团队得分(100分制): 杨灵 ...
- [福大软工] Z班——Alpha现场答辩情况汇总
Alpha现场答辩 小组互评(文字版) 各组对于 麻瓜制造者 的评价与建议 队伍名 评价与建议 *** 界面较友好,安全性不足,功能基本完整.希望能留下卖家的联系方式而不是在APP上直接联系,APP上 ...
- SQL中常用函数
SELECT CONVERT(varchar(100), GETDATE(), 23) AS 日期 结果:2017-01-05 select ISNULL(price,'0.0') ...
- Linux 更改root与home分区大小的方法总结
1. 安装了CentOS7.5的虚拟机 但是发现里面的操作系统 home 分区占到了400g 根分区只有50g 认为不太好,所以要改一下. 2.方法. 好像是xfs的文件格式, 没法使用resize2 ...
- tenda u1 usb wireless device install driver for kali linux kernal Debian 4.3.3-7kali2 (2016-01-27) x86_64 GNU/Linux
因为内核比较新的关系,tenda官方网站上面提供给u1无线网卡的驱动并不能正常编译使用,编译的时候报一个类似错误 /usr/src/linux-headers--kali1-common/Makefi ...
- Bootstrap辅助类
前面的话 Bootstrap提供了一组工具类,用于辅助项目的开发.本文将详细介绍Bootstrap辅助类 文本色 通过颜色来展示意图,Bootstrap 提供了一组工具类.这些类可以应用于链接,并且在 ...