2018 ACM 网络选拔赛 南京赛区
A. An Olympian Math Problem
- #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 main()
- {
- int t;
- ll n;
- scanf("%d",&t);
- while (t--)
- {
- scanf("%lld",&n);
- printf("%lld\n",n-);
- }
- return ;
- }
B. The writing on the wall
与 https://leetcode.com/problems/maximal-rectangle/description/ 这道题很像
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- const ll mod=1e9+;
- const int maxn=1e5+;
- const int maxm=1e2+;
- int a[maxn][maxm],c[maxn][maxm];
- int qx[maxm],qy[maxm];
- int main()
- {
- ll sum=;
- int t,T,n,m,g,x,y,i,j,k;
- bool vis;
- scanf("%d",&t);
- for (T=;T<=t;T++)
- {
- memset(a,,sizeof(a));
- scanf("%d%d%d",&n,&m,&g);
- while (g--)
- {
- scanf("%d%d",&x,&y);
- a[x][y]=;
- }
- for (j=;j<=m;j++)
- for (i=;i<=n;i++)
- c[i][j]=(a[i][j]==)?:c[i-][j]+;
- sum=;
- for (i=;i<=n;i++)
- {
- ///以a[i][j]作为右下方
- g=;
- for (j=;j<=m;j++)
- {
- if (g== || c[i][j]>qx[g])
- vis=;
- else
- vis=;
- sum+=c[i][j];
- qy[g+]=j;
- while (qx[g]>c[i][j])
- sum+=1ll*(qy[g+]-qy[g])*c[i][j],g--;
- k=g;
- while (k)
- sum+=1ll*(qy[k+]-qy[k])*qx[k],k--;
- if (g== || qx[g]!=c[i][j])
- g++;
- if (vis)
- qy[g]=j;
- qx[g]=c[i][j];
- }
- }
- printf("Case #%d: %lld\n",T,sum);
- }
- return ;
- }
- /*
- 100
- 3 3 3
- 1 1
- 1 2
- 2 1
- 3 3 4
- 1 1
- 1 2
- 2 1
- 2 2
- 2 3 0
- 100000 100 0
- */
C. GDY
- #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=2e2+;
- const int maxm=2e4;
- int s[maxm],a[maxn][maxm],g[maxn];
- int value[]={,,,,,,,,,,,,,};
- int cmp(int x,int y)
- {
- return value[x]>value[y];
- }
- int main()
- {
- int t,T,n,m,num,i,j,sum;
- int x,y,z;
- scanf("%d",&t);
- for (T=;T<=t;T++)
- {
- memset(g,,sizeof(g));
- scanf("%d%d",&n,&m);
- for (i=;i<m;i++)
- scanf("%d",&s[i]);
- num=;
- for (i=;i<n;i++)
- {
- for (j=;j<;j++)
- {
- if (num==m)
- break;
- a[i][j]=s[num++];
- }
- sort(a[i],a[i]+j,cmp);
- g[i]=j;
- }
- z=a[][g[]-];//previous number
- g[]--;
- y=;//has y persons
- x=;//pos
- while ()
- {
- for (i=g[x]-;i>=;i--)
- if (value[z]+==value[a[x][i]] || (a[x][i]== && z!=))
- break;
- if (i!=-)
- {
- z=a[x][i];
- a[x][i]=;
- sort(a[x],a[x]+g[x],cmp);
- g[x]--;
- if (g[x]==)
- break;
- y=;
- }
- else if (y!=n-)
- y++;
- else
- {
- x=(x+)%n;
- for (i=x;;i=(i+)%n)
- {
- if (num==m)
- break;
- else
- {
- a[i][g[i]++]=s[num++];
- sort(a[i],a[i]+g[i],cmp);
- }
- if (i==(x-+n)%n)
- break;
- }
- z=a[x][g[x]-];
- g[x]--;
- if (g[x]==)
- break;
- y=;
- }
- x=(x+)%n;
- }
- printf("Case #%d:\n",T);
- for (i=;i<n;i++)
- if (i==x)
- printf("Winner\n");
- else
- {
- sum=;
- for (j=;j<g[i];j++)
- sum+=a[i][j];
- printf("%d\n",sum);
- }
- }
- return ;
- }
- /*
- 10
- 2 6
- 3 5 7 9 11 4
- 3 20
- 2 2 2 2 2 2 2 2 2 2
- 2 2 2 2 2 2 2 2 2 2
- 3 19
- 2 2 2 2 2 2 2 2 2 2
- 2 2 2 2 2 2 2 2 2
- 3 20
- 3 2 2 2 2 2 2 2 2 2 2
- 2 2 2 2 2 2 2 2 2
- 2 10
- 3 4 5 6 7 2 3 4 5 6
- 3 15
- 3 4 5 6 7 12 12 12 12 12 13 13 13 13 13
- 3 11
- 1 2 3 4 5 6 7 8 9 10 11
- 3 13
- 1 2 3 4 5 6 7 8 9 10 11 12 13
- 1
- 3 17
- 1 2 3 4 5 6 7 8 9 10 11 12 13 12 11 10 9
- */
E. AC Challenge
- #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 -1e18
- #define pi 3.1415926536
- #define nl 2.7182818284
- const ll mod=1e9+;//
- const int maxn=1e5+;
- ll f[<<];
- struct node
- {
- ll value;
- int pos,t;
- };
- struct cmp1
- {
- bool operator() (node a,node b)
- {
- return a.value>b.value;
- }
- };
- //priority_queue<node>st;
- priority_queue<node,vector<node>,cmp1>st;
- int er[],a[],b[],v[];
- int main()
- {
- int n,m,s,i,j,value,pos,t;
- ll r=,rr;
- for (i=;i<;i++)
- er[i]=(<<i);
- scanf("%d",&n);
- for (i=;i<(<<n);i++)
- f[i]=inf;
- for (i=;i<n;i++)
- {
- scanf("%d%d%d",&a[i],&b[i],&m);
- v[i]=;
- while (m--)
- {
- scanf("%d",&s);
- v[i]+=(er[s-]);
- }
- if (v[i]==)
- {
- f[er[i]]=a[i]+b[i];
- st.push({a[i]+b[i],er[i],});
- r=max(r,(ll)a[i]+b[i]);
- }
- }
- while (!st.empty())
- {
- value=st.top().value;
- pos=st.top().pos;
- t=st.top().t;
- st.pop();
- for (i=;i<n;i++)
- if ((pos & er[i])== && (pos & v[i])==v[i] && value+1ll*t*a[i]+b[i]>f[pos|er[i]])
- {
- rr=value+1ll*t*a[i]+b[i];
- f[pos|er[i]]=rr;
- r=max(r,rr);
- st.push({rr,pos|er[i],t+});
- }
- }
- printf("%lld",r);
- return ;
- }
- /*
- 3
- 1 2 0
- 1 5 0
- 8 1 0
- */
G. Lpl and Energy-saving Lamps
- #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 1e18
- #define pi 3.1415926536
- #define nl 2.7182818284
- const ll mod=1e9+;//
- const int maxn=1e5+;
- struct node
- {
- int x,y;
- }f[maxn],r[maxn];
- int tag[maxn<<],a[maxn],x,y;
- int cmp(node a,node b)
- {
- return a.x<b.x;
- }
- void build(int index,int l,int r)
- {
- if (l==r)
- scanf("%d",&tag[index]);
- else
- {
- int m=(l+r)>>;
- build(index<<,l,m);
- build(index<<|,m+,r);
- tag[index]=min(tag[index<<],tag[index<<|]);
- }
- }
- int query(int index,int l,int r,int v)
- {
- if (l==r)
- {
- if (tag[index]>v)
- return ;
- x++;
- y-=tag[index];
- tag[index]=inf;
- return l;
- }
- else
- {
- int m=(l+r)>>,z;
- if (tag[index<<]<=v)
- z=query(index<<,l,m,v);
- else
- z=query(index<<|,m+,r,v);
- tag[index]=min(tag[index<<],tag[index<<|]);
- return z;
- }
- }
- int main()
- {
- int n,m,q,Q,d,index,i,j;
- scanf("%d%d",&n,&m);
- build(,,n);
- scanf("%d",&q);
- for (Q=;Q<=q;Q++)
- {
- scanf("%d",&d);
- f[Q].x=d;
- f[Q].y=Q;
- }
- sort(f+,f+q+,cmp);
- index=;
- x=;
- y=;
- for (i=;i<=f[q].x;i++)
- {
- y+=m;
- j=;
- while (j)
- j=query(,,n,y);
- while (f[index].x==i)
- {
- r[f[index].y]={x,y};
- index++;
- }
- }
- for (i=;i<=q;i++)
- printf("%d %d\n",r[i].x,r[i].y);
- return ;
- }
J. Sum
- #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=2e7+;
- int zhi[maxn],f[maxn];
- bool vis[maxn],v[maxn];
- int main()
- {
- int t,i,j,k,x=,y=,value=2e7;
- ll n,sum;
- memset(vis,,sizeof(vis));
- memset(v,,sizeof(v));
- for (i=;i<=value;i++)
- {
- if (!vis[i])
- {
- x++;
- zhi[x]=i;
- }
- for (j=;j<=x;j++)
- {
- k=i*zhi[j];
- if (k>value)
- break;
- vis[k]=;
- v[k]=v[i];
- if (i%zhi[j]==)
- {
- v[k]=;
- break;
- }
- }
- }
- for (i=;i<=value;i++)
- if (!v[i])
- {
- y++;
- f[y]=i;
- }
- // for (i=1;i<=100;i++)
- // printf("%d ",f[i]);
- scanf("%d",&t);
- f[]=;
- while (t--)
- {
- scanf("%lld",&n);
- sum=;
- j=y;
- for (i=;i<=y;i++)
- {
- while (1ll*f[i]*f[j]>n)
- j--;
- sum+=j;
- }
- printf("%lld\n",sum);
- }
- return ;
- }
L. Magical Girl Haze
- /*
- 图问题:
- spfa容易被卡时间复杂度
- 而dijkstra是贪心,不会被卡
- */
- #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 1e18
- #define pi 3.1415926536
- #define nl 2.7182818284
- const ll mod=1e9+;//
- const int maxn=1e5+;
- struct rec
- {
- int d,len;
- rec *to;
- }*e[maxn];
- struct node
- {
- ll dist;
- int k,d;
- };
- struct cmp1
- {
- bool operator() (node a,node b)
- {
- if (a.dist==b.dist)
- return a.k>b.k;
- else
- return a.dist>b.dist;
- }
- };
- priority_queue<node,vector<node>,cmp1>st;
- ll f[maxn][];
- int main()
- {
- rec *p;
- int t,n,m,k,i,j,d,kk,dd,x,y,z;
- ll dist,r;
- scanf("%d",&t);
- while (t--)
- {
- scanf("%d%d%d",&n,&m,&k);
- for (i=;i<=n;i++)
- e[i]=NULL;
- while (m--)
- {
- scanf("%d%d%d",&x,&y,&z);
- p=(rec*) malloc (sizeof(rec));
- p->d=y;
- p->len=z;
- p->to=e[x];
- e[x]=p;
- }
- for (i=;i<=n;i++)
- for (j=;j<=k;j++)
- f[i][j]=inf;
- for (j=;j<=k;j++)
- {
- f[][j]=;
- st.push({,j,});
- }
- //f[i][j]作为一个状态,100000*10
- while (!st.empty())
- {
- dist=st.top().dist;
- d=st.top().d;
- kk=st.top().k;
- st.pop();
- p=e[d];
- while (p)
- {
- dd=p->d;
- if (f[dd][kk]>dist+p->len)
- {
- f[dd][kk]=dist+p->len;
- st.push({f[dd][kk],kk,dd});
- }
- if (kk!=k && f[dd][kk+]>dist)
- {
- f[dd][kk+]=dist;
- st.push({f[dd][kk+],kk+,dd});
- }
- p=p->to;
- }
- }
- r=inf;
- for (j=;j<=k;j++)
- r=min(r,f[n][j]);
- printf("%lld\n",r);
- }
- 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 网络选拔赛 沈阳赛区
B. Call of Accepted #include <cstdio> #include <cstdlib> #include <cmath> #include ...
- ACM-ICPC 2018 南京赛区网络预赛 J.sum
A square-free integer is an integer which is indivisible by any square number except 11. For example ...
- ACM-ICPC 2018 南京赛区网络预赛 E题
ACM-ICPC 2018 南京赛区网络预赛 E题 题目链接: https://nanti.jisuanke.com/t/30994 Dlsj is competing in a contest wi ...
- ACM-ICPC 2018 南京赛区网络预赛B
题目链接:https://nanti.jisuanke.com/t/30991 Feeling hungry, a cute hamster decides to order some take-aw ...
- 计蒜客 30999.Sum-筛无平方因数的数 (ACM-ICPC 2018 南京赛区网络预赛 J)
J. Sum 26.87% 1000ms 512000K A square-free integer is an integer which is indivisible by any squar ...
随机推荐
- MySQL高可用架构-MHA环境部署记录
一.MHA介绍 MHA(Master High Availability)目前在MySQL高可用方面是一个相对成熟的解决方案,它由日本DeNA公司youshimaton(现就职于Facebook公司) ...
- 团队作业 week 14
0. 在吹牛之前,先回答这个问题: 如果你的团队来了一个新队员,有一台全新的机器, 你们是否有一个文档,只要设置了相应的权限,她就可以根据文档,从头开始搭建环境,并成功地把最新.最稳定版本的软件编译出 ...
- linux及安全第五周总结
给MenuOS增加time和time-asm命令 中间过程已省略了,我们所做的只是将menu更新 具体命令如下 rm menu -rf 强制删除 git clone http://github.com ...
- Linux课题实践四——ELF文件格式分析
2.4 ELF文件格式分析 20135318 刘浩晨 ELF全称Executable and Linkable Format,可执行连接格式,ELF格式的文件用于存储Linux程序.ELF文件(目 ...
- 网络:Xen理解
Xen是由剑桥大学计算机实验室开发的一个开源项目.是一个直接运行在计算机硬件之上的用以替代操作系统的软件层,它能够在计算机硬件上并发的运行多个客户操作系统(Guest OS). 一.Xen虚拟化类型 ...
- Github知识小结
软件:计算机运行所需要的各种程序和数据的总成,包括操作系统,汇编语言,编译,程序,数据库,文字编辑和维护使用手册等. 软件的特性:(1)软件产品的主要生产是脑力劳动,还没有摆脱手工开发方式(2)软件是 ...
- net license tool, EasyLicense !
net license tool, EasyLicense ! 开源 .net license tool, EasyLicense ! 介绍: 过去我常常像是否有一个帮助授权的软件,它可以非常简单 ...
- 安装wamp提示You dont't have permission to accesson on this server的解决方案
展示一下安装好的效果图 首先找到安装目录下的路径[wamp\bin\apache\Apache2.2.21\conf\] § 找到httpd.conf,用记事本打开httpd.conf,然后将 1. ...
- 面象对象设计原则之三:里氏替换原则(The Liskov Substitution Principle,LSP)
里氏代换原则由2008年图灵奖得主.美国第一位计算机科学女博士Barbara Liskov教授和卡内基·梅隆大学Jeannette Wing教授于1994年提出.其严格表述如下:如果对每一个类型为S的 ...
- [安全]appscan 使用代理抓取其他客户端的请求
自己安全测试技能很低, 上级给的安全测试的任务给了自动化组的同事来做, 自己之前使用appscan的时候 只知道使用appscan的内置浏览器测试抓取请求 今天与自动化美女同事沟通发现有一个代理的功能 ...