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 垫底纪念的更多相关文章

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

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

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

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

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

  6. Codeforces Round #325 (Div. 2) Phillip and Trains dp

    原题连接:http://codeforces.com/contest/586/problem/D 题意: 就大家都玩过地铁奔跑这个游戏(我没玩过),然后给你个当前的地铁的状况,让你判断人是否能够出去. ...

  7. Codeforces Round #325 (Div. 2) Laurenty and Shop 模拟

    原题链接:http://codeforces.com/contest/586/problem/B 题意: 大概就是给你一个两行的路,让你寻找一个来回的最短路,并且不能走重复的路. 题解: 就枚举上下选 ...

  8. Codeforces Round #325 (Div. 2) Alena's Schedule 模拟

    原题链接:http://codeforces.com/contest/586/problem/A 题意: 大概就是给你个序列..瞎比让你统计统计什么长度 题解: 就瞎比搞搞就好 代码: #includ ...

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

随机推荐

  1. javascript事件类型之界面拖拽交互

    一.在线DEMO 界面拖拽交互

  2. Spring AOP 简单理解

    AOP技术即(面向切面编程)技术是在面向对象编程基础上的发展,AOP技术是对所有对象或一类对象编程.核心是在不增加代码的基础上,还增加了新的功能.AOP编程在开发框架本身用的比较多,而实际项目中,用的 ...

  3. WebApi:WebApi的Self Host模式

    不用IIS也能執行ASP.NET Web API 转载:http://blog.darkthread.net/post-2013-06-04-self-host-web-api.aspx 在某些情境, ...

  4. 不重启程序使用最新版package

    相信很多使用python者都对reload方法比较熟悉了,通过不间断地reload可以实现某一module的热更新,主要就能在不重启应用的情况下实现部分模块的更新.但这种方法仅限于reload当前工作 ...

  5. 网络--三种网络通讯方式及Android的网络通讯机制

    Android平台有三种网络接口可以使用,他们分别是:java.net.*(标准Java接口).Org.apache接口和Android.net.*(Android网络接口).下面分别介绍这些接口的功 ...

  6. 【转】C#环形队列

    概述 看了一个数据结构的教程,是用C++写的,可自己C#还是一个菜鸟,更别说C++了,但还是大胆尝试用C#将其中的环形队列的实现写出来,先上代码: 1 public class MyQueue< ...

  7. 根据 MySQL 状态优化 ---- 3. key_buffer_size

    查看 MySQL 服务器运行的各种状态值: mysql> show global status: 3. key_buffer_size key_buffer_size 是设置 MyISAM 表索 ...

  8. 源码解读—HashTable

    在上一篇学习过HashMap(源码解读—HashMap)之后对hashTable也产生了兴趣,随即便把hashTable的源码看了一下.和hashMap类似,但是也有不同之处. public clas ...

  9. 【原】搭建Samba的简要过程

    1.安装samba yum install samba –y 2.创建用户 useradd admin #先创建系统用户 smbpasswd -a admin #第一次加入需要-a参数,把admin用 ...

  10. LINUX下WIFI默认连接

    #! /bin/sh ifconfig wlan0 upiwconfig wlan0 key 123456iwconfig wlan0 essid "rat-linux"iwcon ...