Codeforces ECR52 div2翻车记
A:签到。
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int read()
{
int x=,f=;char c=getchar();
while (c<''||c>'') {if (c=='-') f=-;c=getchar();}
while (c>=''&&c<='') x=(x<<)+(x<<)+(c^),c=getchar();
return x*f;
}
#define ll long long
int t,a,b,c,d;
int main()
{
t=read();
while (t--)
{
a=read(),b=read(),c=read(),d=read();
cout<<a/d+1ll*a/d/b*c<<endl;
}
return ;
}
B:long long。
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int read()
{
int x=,f=;char c=getchar();
while (c<''||c>'') {if (c=='-') f=-;c=getchar();}
while (c>=''&&c<='') x=(x<<)+(x<<)+(c^),c=getchar();
return x*f;
}
#define N 100010
long long n,m;
int main()
{
cin>>n>>m;
cout<<max(n-m*,0ll)<<' ';
for (long long i=;i<=n;i++) if (i*(i-)/>=m) {cout<<n-i;break;}
return ;
}
C:从大到小排序后贪心地修改。我猜我是唯一一个C花掉的时间比D多的。
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int read()
{
int x=,f=;char c=getchar();
while (c<''||c>'') {if (c=='-') f=-;c=getchar();}
while (c>=''&&c<='') x=(x<<)+(x<<)+(c^),c=getchar();
return x*f;
}
#define N 200010
int n,m,a[N],ans=;
int main()
{
n=read(),m=read();
for (int i=;i<=n;i++) a[i]=read();
sort(a+,a+n+);reverse(a+,a+n+);
for (int i=;a[i]!=a[n];)
{
int t=i;long long tot=;
while (t<n&&tot+1ll*(a[t]-a[t+])*t<=m) tot+=(a[t]-a[t+])*t,t++;
ans++;
i=t;a[i]-=(m-tot)/t;
}
cout<<ans;
return ;
}
D:做法非常显然,每个位置拆点跑个最短路然后大力dp就行了,码农题。
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
int read()
{
int x=,f=;char c=getchar();
while (c<''||c>'') {if (c=='-') f=-;c=getchar();}
while (c>=''&&c<='') x=(x<<)+(x<<)+(c^),c=getchar();
return x*f;
}
#define N 12
int n,f[N*N][],g[N*N][],dis[N*N*][N*N*],dis2[N*N*][N*N*];
struct data{int x,y;
}a[N*N];
int wx[]={,,-,-,,,-,-},wy[]={,-,,-,,-,,-};
int trans(int p,int x,int y){return p*n*n+(x-)*n+y;}
void getdis()
{
memset(dis,,sizeof(dis));memset(dis2,,sizeof(dis2));
for (int i=;i<=n;i++)
for (int j=;j<=n;j++)
for (int x=;x<=n;x++)
for (int y=;y<=n;y++)
if (i==x||j==y) dis[trans(,i,j)][trans(,x,y)]=,dis2[trans(,i,j)][trans(,x,y)]=;
for (int i=;i<=n;i++)
for (int j=;j<=n;j++)
for (int k=;k<;k++)
if (i+wx[k]>=&&j+wy[k]>=&&i+wx[k]<=n&&j+wy[k]<=n)
dis[trans(,i,j)][trans(,i+wx[k],j+wy[k])]=,dis2[trans(,i,j)][trans(,i+wx[k],j+wy[k])]=;
for (int i=;i<=n;i++)
for (int j=;j<=n;j++)
for (int x=;x<=n;x++)
for (int y=;y<=n;y++)
if (i+j==x+y||i-j==x-y) dis[trans(,i,j)][trans(,x,y)]=,dis2[trans(,i,j)][trans(,x,y)]=;
for (int i=;i<=n;i++)
for (int j=;j<=n;j++)
for (int x=;x<;x++)
for (int y=;y<;y++)
dis[trans(x,i,j)][trans(y,i,j)]=dis2[trans(x,i,j)][trans(y,i,j)]=(x!=y);
for (int k=;k<=*n*n;k++)
for (int i=;i<=*n*n;i++)
for (int j=;j<=*n*n;j++)
if (dis[i][k]+dis[k][j]<dis[i][j]||dis[i][k]+dis[k][j]==dis[i][j]&&dis2[i][k]+dis2[k][j]<dis2[i][j])
dis[i][j]=dis[i][k]+dis[k][j],dis2[i][j]=dis2[i][k]+dis2[k][j];
}
void update(int i,int p)
{
for (int j=;j<;j++)
if (f[i-][j]+dis[trans(j,a[i-].x,a[i-].y)][trans(p,a[i].x,a[i].y)]<f[i][p]||
f[i-][j]+dis[trans(j,a[i-].x,a[i-].y)][trans(p,a[i].x,a[i].y)]==f[i][p]
&&g[i-][j]+dis2[trans(j,a[i-].x,a[i-].y)][trans(p,a[i].x,a[i].y)]<g[i][p])
f[i][p]=f[i-][j]+dis[trans(j,a[i-].x,a[i-].y)][trans(p,a[i].x,a[i].y)],
g[i][p]=g[i-][j]+dis2[trans(j,a[i-].x,a[i-].y)][trans(p,a[i].x,a[i].y)];
}
int main()
{
n=read();
for (int i=;i<=n;i++)
for (int j=;j<=n;j++)
{
int x=read();
a[x].x=i,a[x].y=j;
}
getdis();
memset(f,,sizeof(f));memset(g,,sizeof(g));
f[][]=f[][]=f[][]=g[][]=g[][]=g[][]=;
for (int i=;i<=n*n;i++)
update(i,),update(i,),update(i,);
int x=;
if (f[n*n][]<f[n*n][]||f[n*n][]==f[n*n][]&&g[n*n][]<g[n*n][]) x=;
if (f[n*n][]<f[n*n][x]||f[n*n][]==f[n*n][x]&&g[n*n][]<g[n*n][x]) x=;
cout<<f[n*n][x]<<' '<<g[n*n][x];
return ;
}
然后就并没有时间看题了。不过E是置换并没有真的学过那大概也不算翻车了。
upd:于是就发现F是个傻逼题。将所有边连上缩个点dp一发即可。
result:rank 217 rating +7 迷之稳定。
Codeforces ECR52 div2翻车记的更多相关文章
- Codeforces #180 div2 C Parity Game
// Codeforces #180 div2 C Parity Game // // 这个问题的意思被摄物体没有解释 // // 这个主题是如此的狠一点(对我来说,),不多说了这 // // 解决问 ...
- Codeforces #541 (Div2) - E. String Multiplication(动态规划)
Problem Codeforces #541 (Div2) - E. String Multiplication Time Limit: 2000 mSec Problem Descriptio ...
- Codeforces #541 (Div2) - F. Asya And Kittens(并查集+链表)
Problem Codeforces #541 (Div2) - F. Asya And Kittens Time Limit: 2000 mSec Problem Description Inp ...
- Codeforces #541 (Div2) - D. Gourmet choice(拓扑排序+并查集)
Problem Codeforces #541 (Div2) - D. Gourmet choice Time Limit: 2000 mSec Problem Description Input ...
- Codeforces #548 (Div2) - D.Steps to One(概率dp+数论)
Problem Codeforces #548 (Div2) - D.Steps to One Time Limit: 2000 mSec Problem Description Input Th ...
- A · F · O —— JLOI2018翻车记(附Day1简要题解)
JLOI2018翻车记 并不知道该怎么写... 算了还是按照标准剧情来吧 这应该是一篇写得非常差的流水账... 2018.04.04 Day -1 省选前在机房的最后一天. 压力并不是很大,毕竟联赛 ...
- 行车记+翻车记:.NET Core 新车改造,C# 节能降耗,docker swarm 重回赛道
非常抱歉,10:00~10:30 左右博客站点出现故障,给您带来麻烦了,请您谅解. 故障原因与博文中谈到的部署变更有关,但背后的问题变得非常复杂,复杂到我们都在怀疑与阿里云服务器 CPU 特性有关. ...
- 【Codeforces #312 div2 A】Lala Land and Apple Trees
# [Codeforces #312 div2 A]Lala Land and Apple Trees 首先,此题的大意是在一条坐标轴上,有\(n\)个点,每个点的权值为\(a_{i}\),第一次从原 ...
- Codeforces Round#500 Div.2 翻车记
A:签到 #include<iostream> #include<cstdio> #include<cmath> #include<cstdlib> # ...
随机推荐
- 北京Uber优步司机奖励政策(11月30日~12月4日)
用户组:人民优步(适用于12月1日)奖励政策: 滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:htt ...
- day 6 老王开枪打人
1.图示 2 程序 1)版本1:框架的搭建 def main(): '''用来控制这个程序的流程''' pass #1.创建alex对象 #2.创建1个枪对象 #3.创建1个弹夹对象 #4.创建子弹对 ...
- ORB-SLAM(十一)EPnP
EPnP在ORB-SLAM中主要用于Tracking线程中的重定位Relocalization模块,需要通过当前关键帧Bow与候选帧匹配上的3D地图点,迅速建立当前相机的初始姿态. PnP问题解决了已 ...
- Ruby & Rails学习资料
------------------教程------------- Ruby风格指南(代码规范) https://github.com/bbatsov/ruby-style-guide 笨方法學 Ru ...
- git 操作几个命令
git clone ssh://lijianfeng@192.168.1.246:29418/GMGameSDK压栈:git stash查状态:git status切换到要修改的提交:git reb ...
- Ubuntu目录与权限
Ubuntu目录 / /bin /sbin /boot /etc /mnt /home d :directory - :file b :block 磁盘以块进行 l :link Ubuntu权限 U ...
- Anyproxy抓包工具
1.安装Nodejs和AnyProxy以及安装模拟器(移动端抓包工具) 第一步:nodejs下载地址:http://nodejs.cn/download/ 下载Windows版本,直接运行安装即可, ...
- nginx 重启报错
错误信息: nginx: [error] open() "/usr/local/nginx/logs/nginx.pid" failed (2: No such file or d ...
- Appium ——Android KEYCODE键值:
Python下语法: driver.keyevent(键值) 电话按键: 键名 描述 键值 KEYCODE_CALL 拨号键 5 KEYCODE_ENDCALL 挂机键 6 KEYCODE_HOME ...
- 查看python中包的文档
核心命令:python -m pydoc 查询某包:python -m pydoc 包名 示例: C:\Users\xxx>python -m pydoc pydoc - the Python ...