Codeforces Round #325 垫底纪念
A. Alena's Schedule
间隔0长度为1被记录 1被记录 其余不记录
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <vector>
using namespace std;
int main()
{
int t;
cin>>t;
int pre = ;
int a = ,ans= ;
bool mk = false;
while(t--)
{
cin>>a;
if(a)
{
if(pre<)
ans+=pre;
pre=;
ans+=;
mk=true;
}
else{
if(mk)
{
pre++;
}
}
}
cout<<ans<<endl;
return ;
}
AC代码
B. Laurenty and Shop
前缀后缀枚举转折点。
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <climits>
using namespace std;
int a[],b[];
int main()
{
int t;
cin>>t;
int x;
for(int i=;i<t;i++) // 0 1 2 3
{
cin>>x;
a[i] = a[i-] + x;
}
for(int i=;i<t;i++) // 0 1 2 3
{
cin>>x;
b[i] = b[i-] + x;
}
vector<int>v;
for(int i=;i<t;i++)
{
cin>>x;
v.push_back(a[i]+b[t-]-b[i]+x);
}
sort(v.begin(),v.end());
cout<<v[]+v[]<<endl;
return ;
}
AC代码
C. Gennady the Dentist
读不懂 模拟题
D. Phillip and Trains
每次向右走一格,所以我们只要确定他活过m轮,就一定到达终点。//
判断车的位置 当前位置加2×t 车的位置不容易改变所以我们把自己加上2×t相当于车往左走了2×t 判断是否合法即可
比赛的时候vis标记位置放错....还是太菜了呢
就是太菜,不想找什么英语差的借口了
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <vector>
using namespace std;
bool vis[][];
char ch[][];
int n,m;
typedef pair<int,int> pii;
bool check(int x,int y,int dir,int t,vector<pii>& now)
{
int nx = dir+x;
int ny = y+;
if(nx<||nx>=n||ny<||ny>=m||vis[nx][ny]) return false;
int a,b,c;
a = (y+*t+);
b = (a+);
c = (b+);
if(dir)
{
if((a<m&&ch[x][a]!='.')) return false;
}
if((a<m&&ch[nx][a]!='.')||(b<m&&ch[nx][b]!='.')||(c<m&&ch[nx][c]!='.')) return false;
now.push_back(make_pair(nx,ny));
vis[nx][ny] = true;
return true;
} bool bfs(int x,int y)//shijiweizhi
{
vector<pii>now,nxt;
now.push_back(make_pair(x,y));
int time = ;
vis[x][y] = true;
while(now.size())
{
if(time>=m) break;
for(int i=;i<now.size();i++)
{
//printf("%d %d %d",time,now[i].first,now[i].second);
for(int j=-;j<=;j++)
{
check(now[i].first,now[i].second,j,time,nxt);
}
}
swap(now,nxt);
nxt.clear();
time++;
}
return time>=m;
}
int main()
{
int t;
cin>>t;
while(t--)
{
memset(vis,,sizeof(vis));
memset(ch,,sizeof(ch));
int k;
scanf("%d%d",&m,&k);
n = ;
int sx,sy;
for(int i=;i<n;i++)
{
scanf("%s",ch[i]);
for(int j=;j<m;j++)
{
if(ch[i][j]=='s')
{
ch[i][j] = '.';
sx = i;
sy = j;
}
}
}
//cout<<sx<<sy<<endl;
if(bfs(sx,sy)) puts("YES");
else puts("NO");
}
return ;
}
AC代码
E. Alice, Bob, Oranges and Apples
每个人操作的次数就是GCD的过程
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <string.h>
#include <cctype>
#include <climits>
using namespace std;
typedef long long ll;
char ch = 'A';
bool mk;
ll gcd(ll a,ll b)
{
if(b==) return a;
ll val = a/b;
if(val)
{
if(a%b==) val--;
if(val)
{
cout<<val<<char(ch+mk);
mk = !mk;
}
} return gcd(b,a%b);
}
int main()
{
ll x,y;
cin>>x>>y;
mk = x<y;
if(__gcd(x,y)!=)
{
printf("Impossible");
}
else{
gcd(x,y);
}
return ;
}
AC代码
Codeforces Round #325 垫底纪念的更多相关文章
- Codeforces Round #325 (Div. 2) F. Lizard Era: Beginning meet in the mid
F. Lizard Era: Beginning Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/5 ...
- Codeforces Round #325 (Div. 2) D. Phillip and Trains BFS
D. Phillip and Trains Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/586/ ...
- Codeforces Round #325 (Div. 2) C. Gennady the Dentist 暴力
C. Gennady the Dentist Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/586 ...
- Codeforces Round #325 (Div. 2) A. Alena's Schedule 水题
A. Alena's Schedule Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/586/pr ...
- Codeforces Round #325 (Div. 2) B. Laurenty and Shop 前缀和
B. Laurenty and Shop Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/586/p ...
- Codeforces Round #325 (Div. 2) Phillip and Trains dp
原题连接:http://codeforces.com/contest/586/problem/D 题意: 就大家都玩过地铁奔跑这个游戏(我没玩过),然后给你个当前的地铁的状况,让你判断人是否能够出去. ...
- Codeforces Round #325 (Div. 2) Laurenty and Shop 模拟
原题链接:http://codeforces.com/contest/586/problem/B 题意: 大概就是给你一个两行的路,让你寻找一个来回的最短路,并且不能走重复的路. 题解: 就枚举上下选 ...
- Codeforces Round #325 (Div. 2) Alena's Schedule 模拟
原题链接:http://codeforces.com/contest/586/problem/A 题意: 大概就是给你个序列..瞎比让你统计统计什么长度 题解: 就瞎比搞搞就好 代码: #includ ...
- Codeforces Round #325 (Div. 2) D bfs
D. Phillip and Trains time limit per test 1 second memory limit per test 256 megabytes input standar ...
随机推荐
- CentOS6.8 MySQL 5.6实现主从复制
主库操作 1.将mysqldump命令添加到/usr/bin中 ln -s /application/mysql/bin/mysqldump /usr/bin/ 2.开启master上的log-bin ...
- AutoFac使用~IOC容器(DIP,IOC,DI)
#cnblogs_post_body h1 { background-color: #A5A5A5; color: white; padding: 5px } Autofac一款IOC容器,据说比Sp ...
- Oracle常见的几种等待事件
1. CPU time CPU time其实不是真正的等待事件.是衡量CPU是否瓶颈的一个重要指标.一般来讲,一个良好的系统,CPU TIME 应该排在TOP 5 TIME Event的最前面. 当然 ...
- 一些实用的linux命令
一直在用linux,可linux下的命令还是用得不是很熟悉,记录一下比较有用命令: ``和$()是一样的,都是用指令的执行结果来替换. linux下 echo hello world => ...
- Redis 新特性---pipeline(管道)
转载自http://weipengfei.blog.51cto.com/1511707/1215042 Redis本身是一个cs模式的tcp server, client可以通过一个socket连续发 ...
- Oracle linux6.1配置yum本地源
一.准备工作1. Linux安装盘插入光驱2. 挂载光驱 [root@localhost ~]# mount /dev/cdrom /mnt/ mount: block device /dev/sr0 ...
- LeetCode 342. Power of Four
Given an integer (signed 32 bits), write a function to check whether it is a power of 4. Example:Giv ...
- IMX6下移植WKxxx驱动
wkXXX.c #include<linux/init.h> #include <linux/module.h> #include <linux/kernel.h> ...
- 关于position:absolute的困惑
今天在学习<精通css>时碰到一个问题,第六章“对列表应用样式和创建导航条”中的“Suckerfish下拉菜单”中,为了创建导航条的下拉菜单,文中提到的方法是:先设置下拉菜单的positi ...
- 交换两个数-c++实现
今天看了下交换数值的小程序,网上挺多的,整理了下,,因为参考较多,没一一给出链接,若原作者看到,可以留言,我会添加 // example_1_6_function_swap.cpp : 定义控制台应用 ...