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 网络选拔赛 沈阳赛区的更多相关文章

  1. 2018 ACM 网络选拔赛 青岛赛区

    一些题目的代码被网站吞了…… Problem B. Red Black Tree http://acm.zju.edu.cn/onlinejudge/searchProblem.do?contestI ...

  2. 2018 ACM 网络选拔赛 北京赛区

    A Saving Tang Monk II #include <bits/stdc++.h> using namespace std; ; struct node { int x,y,z, ...

  3. 2018 ACM 网络选拔赛 徐州赛区

    A. Hard to prepare #include <cstdio> #include <cstdlib> #include <cmath> #include ...

  4. 2018 ACM 网络选拔赛 焦作赛区

    A. Magic Mirror #include <cstdio> #include <cstdlib> #include <cmath> #include < ...

  5. 2018 ACM 网络选拔赛 南京赛区

    A. An Olympian Math Problem #include <cstdio> #include <cstdlib> #include <cmath> ...

  6. ACM-ICPC 2018 沈阳赛区网络预赛 K Supreme Number(规律)

    https://nanti.jisuanke.com/t/31452 题意 给出一个n (2 ≤ N ≤ 10100 ),找到最接近且小于n的一个数,这个数需要满足每位上的数字构成的集合的每个非空子集 ...

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

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

  9. 图上两点之间的第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 ...

随机推荐

  1. [转载]sql 盲注之正则表达式攻击

    [转载]sql 盲注之正则表达式攻击 -----------------------------------------MYSQL 5+-------------------------------- ...

  2. Python数据类型-7

    什么数据类型. int 1,2,3用于计算. bool:True,False,用户判断. str:存储少量数据,进行操作 'fjdsal' '二哥','`13243','fdshklj' '战三,李四 ...

  3. 【CV】ICCV2015_Unsupervised Learning of Visual Representations using Videos

    Unsupervised Learning of Visual Representations using Videos Note here: it's a learning note on Prof ...

  4. SQL 别名

    Sql中添加别名有三种方式:

  5. squid反向代理

    反向代理的作用是就爱那个网站中的静态自原本地化.也就是将一部分本应该有原是服务器处理的请求交给 Squid 缓存服务处理 编辑 Squid  服务程序的配置文件*(正向代理与反向代理不能同时使用,) ...

  6. MES架构

    FlexWeaver作为速威公司全新一代MES的技术平台,提供MES所需的全系列平台服务,针对工业大数据提供分布式计算环境.统一数据库引擎.大数据及云计算支撑等等. ● 同时适应企业内网服务器及云部署 ...

  7. flask+mako+peewee(上)

    其实关于什么用flask搭建一个后台博客啥的跟着官方文档做一遍就行了.感觉啥都有我这里就不赘述了只是记录一个笔记,因为稍微有几个地方有点坑. 目标:做了一个简易页面给电商的同事用来添加商品 首先是安装 ...

  8. 自省 另外一种python 生成随机在base36 之间的兑换码生成。

    放假无聊,翻看自己博客的时候发现自己前面写的 那个base36兑换码在翻阅的时候 想到一个更简单的办法实现.但是随机上来说可能没有前者那么高 但是觉得也没有多大的问题 发上来 自己再想想 import ...

  9. Security Testing Test Scenarios

    1 check for sql injection attacks2 secure pages should use https protocol3 page crash should not rev ...

  10. java.util.concuttent Callable Future详解

    在传统的多线程实现方式中(继承Thread和实现Runnable)无法直接获取线程执行的返回结果,如果需要获取执行结果,就必须通过共享变量或者使用线程通信的方式来达到效果,这样使用起来就比较麻烦. 从 ...