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)的更多相关文章

  1. Codeforces Beta Round #80 (Div. 2 Only)【ABCD】

    Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...

  2. Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】

    Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...

  3. Codeforces Beta Round #79 (Div. 2 Only)

    Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...

  4. Codeforces Beta Round #77 (Div. 2 Only)

    Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...

  5. Codeforces Beta Round #76 (Div. 2 Only)

    Codeforces Beta Round #76 (Div. 2 Only) http://codeforces.com/contest/94 A #include<bits/stdc++.h ...

  6. Codeforces Beta Round #75 (Div. 2 Only)

    Codeforces Beta Round #75 (Div. 2 Only) http://codeforces.com/contest/92 A #include<iostream> ...

  7. Codeforces Beta Round #74 (Div. 2 Only)

    Codeforces Beta Round #74 (Div. 2 Only) http://codeforces.com/contest/90 A #include<iostream> ...

  8. Codeforces Beta Round #73 (Div. 2 Only)

    Codeforces Beta Round #73 (Div. 2 Only) http://codeforces.com/contest/88 A 模拟 #include<bits/stdc+ ...

  9. Codeforces Beta Round #72 (Div. 2 Only)

    Codeforces Beta Round #72 (Div. 2 Only) http://codeforces.com/contest/84 A #include<bits/stdc++.h ...

随机推荐

  1. clientX,screenX,pageX,offsetX的异同

    pageX/pageY: 鼠标相对于整个页面的X/Y坐标.注意,整个页面的意思就是你整个网页的全部,比如说网页很宽很长,宽2000px,高3000px,那pageX,pageY的最大值就是它们了. 特 ...

  2. 开源小程序CMS网站, JeeWx-App-CMS 1.0 首版本发布

    JeeWx-App-CMS 是jeewx开发的小程序网站开源项目,基于小程序wepy语言,具备cms网站的基本功能,能够打造简单易用的小程序公司官网.项目结构简单,逻辑清晰,代码规范,非常适合作为小程 ...

  3. WDA-Webdynpro应用发布至EP

    主要是记录下Webdynpro应用发布到EP端的整个操作过程. 1.系统管理System Administration 定义与后台应用系统R3的连接 1.1设置连接参数 路径:System Admin ...

  4. js ajax 数据获取

    在js中应用ajax 获取数据的方法,也写一个出来供复习所用 1.建议一个user.json 文件如下,保存名字为 user.json { "name": "huanyi ...

  5. PDF文档的目录编辑与显示

    为了更好的保护PDF文件,可以将其转换为图片的格式,再重新排版编辑. 使用压缩率更高的JPEG 2000图片格式更佳. ---------------------------------------- ...

  6. Unable to locate Spring NamespaceHandler for XML schema namespace

    1. 问题 本文将讨论Spring中最常见的配置问题 —— Spring的一个命名空间的名称空间处理程序没有找到. 大多数情况下,是由于一个特定的Spring的jar没有配置在classpath下,让 ...

  7. redis集群报错:(error) MOVED 11469 192.168.163.249:7002

    应该是你没有启动集群模式(即缺少了那个"-c"): redis-cli -c -h yourhost -p yourpost

  8. fopen函数出现段错误

    昨天写代码的时候突然发现了一个问题,当使用fopen("<filepath>", "r")时,如果filepath不存在,那么fopen函数并不是像 ...

  9. 微信定时获取token

    为了使第三方开发者能够为用户提供更多更有价值的个性化服务,微信公众平台开放了许多接口,包括自定义菜单接口.客服接口.获取用户信息接口.用户分组接口.群发接口等,开发者在调用这些接口时,都需要传入一个相 ...

  10. splunk + docker-compose 实现自定义 index

    splunk是一款非常优秀的运维管理平台.Splunk 是机器数据的引擎.使用 Splunk 可收集.索引和利用所有应用程序.服务器和设备生成的快速移动型计算机数据 . 使用 Splunking 处理 ...