Codeforces Beta Round #52 (Div. 2)
Codeforces Beta Round #52 (Div. 2)
http://codeforces.com/contest/56
A
#include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define pb push_back
#define eb emplace_back
#define maxn 1000005
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef unsigned long long ull; int n; int main(){
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
cin>>n;
map<string,int>mp;
mp["ABSINTH"]++;
mp["BEER"]++;
mp["BRANDY"]++;
mp["CHAMPAGNE"]++;
mp["GIN"]++;
mp["RUM"]++;
mp["SAKE"]++;
mp["TEQUILA"]++;
mp["VODKA"]++;
mp["WHISKEY"]++;
mp["WINE"]++;
string str;
int ans=;
for(int i=;i<=n;i++){
cin>>str;
int tmp=;
if(str[]>=''&&str[]<=''){
for(int j=;j<str.length();j++){
tmp=tmp*+str[j]-'';
}
if(tmp<) ans++;
}
else{
if(mp[str]) ans++;
}
}
cout<<ans<<endl;
}
B
#include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define pb push_back
#define eb emplace_back
#define maxn 1000005
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef unsigned long long ull; int n;
int a[];
int book[]; int main(){
#ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
cin>>n;
int L=,R=;
int co=;
int cc=;
for(int i=;i<=n;i++) {
cin>>a[i];
if(a[i]!=i){
book[i]=;
if(L!=) R=i;
if(L==) L=i;
}
}
int pre=0x3f3f3f3f;
int flag=;
for(int i=;i<=n;i++){
if(book[i]){
if(pre<a[i]){
flag=;
}
pre=a[i];
}
}
if(flag) cout<<"0 0"<<endl;
else{
cout<<L<<" "<<R<<endl;
}
}
C
模拟
#include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define pb push_back
#define eb emplace_back
#define maxn 1000005
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef unsigned long long ull;
char S;
int n,ans;
string s[]; int main(){
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
while(cin>>S)
{
if(S=='.')
{
for(int i=;i<n;i++)
if(s[i]==s[n])
ans++;
s[n]="";
n--;
}
else
if(S==':' || S==',')
n++;
else
s[n]+=S;
}
cout<<ans<<endl;
}
D
DP +路径搜索,基础DP, 类似一道名为编辑距离的题目
#include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define pb push_back
#define eb emplace_back
#define maxn 1000005
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef unsigned long long ull; string s1,s2;
int dp[][]; void dfs(int i,int j){
if(i==&&j==) return;
if(i&&dp[i-][j]+==dp[i][j]){
dfs(i-,j);
cout<<"DELETE"<<" "<<j+<<endl;
}
else if(j&&dp[i][j-]+==dp[i][j]){
dfs(i,j-);
cout<<"INSERT"<<" "<<j<<" "<<s2[j-]<<endl;
}
else{
dfs(i-,j-);
if(s1[i-]!=s2[j-])
cout<<"REPLACE"<<" "<<j<<" "<<s2[j-]<<endl;
}
} int main(){
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
cin>>s1>>s2;
int len1=s1.length();
int len2=s2.length();
rep(i,,len1+) dp[i][]=i;
rep(i,,len2+) dp[][i]=i;
dp[][]=;
rep(i,,len1+){
rep(j,,len2+){
dp[i][j]=min(min(dp[i-][j],dp[i][j-])+,dp[i-][j-]+(s1[i-]!=s2[j-]));
}
}
cout<<dp[len1][len2]<<endl;
dfs(len1,len2);
}
E
DP 从后往前推,找出符合的距离 。想到逆向思路就很简单了
#include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define pb push_back
#define eb emplace_back
#define maxn 1000005
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef unsigned long long ull; int n;
struct sair{
int x,h,pos,num;
}a[]; bool cmp(sair a,sair b){
return a.x<b.x;
} bool cmp1(sair a,sair b){
return a.pos<b.pos;
} int main(){
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
cin>>n;
for(int i=;i<=n;i++){
cin>>a[i].x>>a[i].h;
a[i].pos=i;
a[i].num=;
}
sort(a+,a+n+,cmp);
for(int i=n-;i>=;i--){
int j=i+;
while(j<=n&&a[i].x+a[i].h>a[j].x){
a[i].num+=a[j].num;
j=a[j].num+j;
}
}
sort(a+,a+n+,cmp1);
for(int i=;i<=n;i++){
cout<<a[i].num<<" ";
} }
Codeforces Beta Round #52 (Div. 2)的更多相关文章
- Codeforces Beta Round #80 (Div. 2 Only)【ABCD】
Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...
- Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】
Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...
- Codeforces Beta Round #79 (Div. 2 Only)
Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...
- Codeforces Beta Round #77 (Div. 2 Only)
Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...
- Codeforces Beta Round #76 (Div. 2 Only)
Codeforces Beta Round #76 (Div. 2 Only) http://codeforces.com/contest/94 A #include<bits/stdc++.h ...
- Codeforces Beta Round #75 (Div. 2 Only)
Codeforces Beta Round #75 (Div. 2 Only) http://codeforces.com/contest/92 A #include<iostream> ...
- Codeforces Beta Round #74 (Div. 2 Only)
Codeforces Beta Round #74 (Div. 2 Only) http://codeforces.com/contest/90 A #include<iostream> ...
- Codeforces Beta Round #73 (Div. 2 Only)
Codeforces Beta Round #73 (Div. 2 Only) http://codeforces.com/contest/88 A 模拟 #include<bits/stdc+ ...
- Codeforces Beta Round #72 (Div. 2 Only)
Codeforces Beta Round #72 (Div. 2 Only) http://codeforces.com/contest/84 A #include<bits/stdc++.h ...
随机推荐
- 用Redis实现分布式锁 与 实现任务队列
这一次总结和分享用Redis实现分布式锁 与 实现任务队列 这两大强大的功能.先扯点个人观点,之前我看了一篇博文说博客园的文章大部分都是分享代码,博文里强调说分享思路比分享代码更重要(貌似大概是这个意 ...
- Apache通过配置.htaccess文件禁止访问.git、.svn等目录
如果你用过Git.SVN等代码版本控制工具的话,那肯定会知道,如果你需要拉去最新的代码到本地时,会自动生成一个.git或者.svn文件夹,里面包含一些项目相关的信息,如果在部署项目是,把这些文件公开暴 ...
- 如何禁用Firefox,chrome浏览器“不安全密码警告”
在任何HTTP页面中,一个全新的“不安全密码警告”将会在用户点击表单时直接出现在登陆框的下方,强行保证所有用户都能看到“此链接不安全,你的个人利益将受到损害”等字眼,同时整个页面也会收到损坏的挂锁图标 ...
- html to docx
public static void main(String[] args) throws Exception{ //创建 POIFSFileSystem 对象 POIFSFileSystem poi ...
- Django - cookies 会话跟踪技术
一.HTTP协议的无状态保存 两次请求之间没有关联 会话理解为客户端与服务器之间的一次会晤,在一次会晤中可能会包含多次请求和响应 2.会话路径技术使用Cookie或session完成 我们知道HTTP ...
- ORA-00600: internal error code, arguments: [4193]问题解决
操作环境 SuSE+Oracle11gR2 问题现象 单板宕机自动重启后,ORACLE运行不正常,主要表现如下: 1.执行shutdown immedate停止数据库时,提示ORA-00600: in ...
- Android Bug:Error:com.android.dex.DexException: Multiple dex files define Landroid/support/design/widget/CoordinatorLayout$LayoutParams;
项目编译通过,运行时出现异常: Error:com.android.dex.DexException: Multiple dex files define Landroid/support/desig ...
- C++ CSTRINGLIST用法
CStringList类成员 构造 CStringList 构造一个空的CString对象列表 首/尾访问 GetHead 返回此列表(不能是空的)中头部的元素 GetTail 返回此列表(不能是 ...
- Hadoop集群(一) Zookeeper搭建
作为Hadoop初学者,自然要从安装入手.而hadoop的优势就是分布式,所以,也一定要安装分布式的系统. 整体安装步骤,包括Zookeeper+HDFS+Hbase,为了文章简洁,我会分三篇blog ...
- python os模块的使用(转)
os模块包含普遍的操作系统功能. 注意:函数参数path是文件或目录的路径,filename是文件的路径,dirname是目录的路径,路径可以是相对路径,也可绝对路径 常见或重要的函数为加粗字体 os ...