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 ...
随机推荐
- Javascript操作Cookie的脚本 — CookieHelper
var HttpCookie = function(name, value, expires, path, domain) { if (name) this.Name = name; if (valu ...
- 网站tomcat配置
<?xml version='1.0' encoding='utf-8'?> <!-- Licensed to the Apache Software Foundation (ASF ...
- BufferedReader需要显示关闭
BufferedReader reader = new BufferedReader(); …… reader.close(); BufferedReader需要显示关闭 解释: 方法调用结束后,这两 ...
- List remove注意点
public class ListTest { public static void main(String[] args) { // TODO Auto-generated method stub ...
- 使用Script Component源处理不规则平面文件
微软 BI 系列随笔 - SSIS 2012 高级应用 - Script Component处理不规则平面文件 场景介绍 在使用SSIS从平面文件导入源数据时,最常遇到的是以下两种情况: 导入规则的平 ...
- [转载]强烈推荐学习的blog
膜拜大牛 原文出处:http://hedengcheng.com/?p=676 ACM Queue (Architecting Tomorrow’s Computing) 网址:http://queu ...
- 必须使用“角色管理工具”安装或配置Microsoft .NET Framework 3.5 SP1
在Windows Server 2008下直接安装SQL Server 2008时,会出现如下错误: 必须使用“角色管理工具”安装或配置Microsoft .NET Framework 3.5 SP1 ...
- 字符串连接,数字tostring,写入文件
#include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { int x=2410; in ...
- nodejs-express 报错View is not a constructor
可能是express版本问题 view修改为views – app.set('views',__dirname + '/views');
- delphi中Message消息的使用方法
实例1 unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls ...