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 ...
随机推荐
- TP的di
依赖注入的意思是通过反射分析类所依赖的其他类,从容器中获取相应的对象并自动注入到类里面 首先依赖注入和控制反转说的是同一个东西,是一种设计模式,这种设计模式用来减少程序间的耦合,鄙人学习了一下,看TP ...
- C++中多态中构造函数与析构函数的调用
做个实验,看一下成员变量的构造析构,父类子类的构造析构,以及虚函数对调用的影响. #include <iostream> using namespace std; class Member ...
- call 和 apply
call和apply作用一样,都是为了转移this,区别在于传入参数的方式不同. this指当前方法所在的对象,如果方法的外面没有对象,则默认是window.由于闭包虽在调用的方法中,但是在创建的时候 ...
- APP-8-文本语音
1.百度语音合成JS文件 baidu_tts_cors.js /** * 浏览器调用语音合成接口 * @param {Object} param 百度语音合成接口参数 * 请参考 https://ai ...
- pgsql restart
/etc/init.d/postgresql restart
- 微信、陌陌等著名IM软件设计架构详解(转)
对微信.陌陌等进行了分析,发出来分享一下(时间有些久了) 电量:对于移动设备最大的瓶颈就是电量了.因为用户不可能随时携带电源,充电宝.所以必须考虑到电量问题.那就要检查我们工程是不是有后台运行,心跳包 ...
- linux 2.6.32.220的一个crash记录
有同事分析一个crash,我参与了分析,记录如下,供遇到相同crash的兄弟参考: crash> bt PID: TASK: ffff881723ce8080 CPU: COMMAND: &qu ...
- Java设置运行时环境参数
一.代码中,如下: System.setProperty("java.util.concurrent.ForkJoinPool.common.parallelism", " ...
- python实现根据指定字符截取对应的行的内容
工作中遇到的,在一个.c文件中有很多函数,这个.c是自动生成的,需要将所有的函数通过extern放到.h中,每个函数都是UINT32 O_开头,通过正则表达式进行字符匹配以及通过linecache来截 ...
- 17.struts-开发流程.md
目录 struts2.3.4 基本步骤 1. 导包,struts2.3有八个包要导入 2. 配置web.xml,引入struts核心功能,配置过滤器 3. 开发action 4. 配置action s ...