cf1234-div3
A
水题
B
直接看2,发现`unordered_map被卡了。。。`
乖乖离散化
C
有六种水管,可以任意的旋转,使得有一条从(1, 0)到(2, n)的通路。
找规律,当时写D没来得及看
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<queue>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<bitset> using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
#define pb(x) push_back(x)
#define cls(x, val) memset(x, val, sizeof(x))
#define fi first
#define se second
#define mp(x, y) make_pair(x, y)
#define inc(i, l, r) for(int i=l; i<=r; i++)
const int inf = 0x3f3f3f3f;
const int maxn = +;
int n;
string s[]; int main(){
ios::sync_with_stdio(false);
int _;
cin>>_;
while(_--){
cin>>n;
cin>>s[]>>s[];
int row=;
int pos = ;
for(pos=; pos<n; pos++){
if(s[row][pos]>=''){
if(s[row^][pos]<'') break;
else {
row ^= ;
}
}
//cout<<row<<" "<<pos<<endl;
}
//cout<<"lst "<<row<<" "<<pos<<endl;
if(row == &&pos == n){
cout<<"YES"<<endl;
}else cout<<"NO"<<endl;
} return ;
}
D
很裸的线段树,第一次正式的比赛AC了线段树,虽然很裸。。。
E
看起来很复杂的算式计算,不想补了。。
F SOS dp
原题意:
给一个字符串,长度可达1e6,最多翻转一个子串,使得最后选择一个子串,使得该子串包含的不同的字母的个数最大。
题意转换:
找两个不想交的子串,使得不相同的子串的个数最多。
1. 计算所有的子串的最大个数
2. 更新所有的集合i中包含的不同字母的最大个数。(dp[i]表示i的子集中的最大不同字母个数)
3. $ans = max(ans, dp[i]+dp[i \quad xor \quad all])$
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<queue>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<bitset> using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
#define pb(x) push_back(x)
#define cls(x, val) memset(x, val, sizeof(x))
#define fi first
#define se second
#define mp(x, y) make_pair(x, y)
#define inc(i, l, r) for(int i=l; i<=r; i++)
const int inf = 0x3f3f3f3f;
const int maxn = 1e6+; int n, m, k; char s[maxn]; int dp[<<]; int main(){
while(~scanf("%s",s+)){
n = strlen(s + );
for(int i=;i<=n;i++) s[i] -= 'a'; memset(dp,,sizeof(dp));
for(int i=;i<=n;i++){
int x = , c = ;
for(int j=i;j<=n;j++){
if((x >> s[j]) & ) break;
x |= ( << s[j]); c++;
dp[x] = c;
}
} for(int i=;i<;i++){
for(int mask=;mask<(<<);mask++){
if((mask>>i)&){
//原来是仅有的几个状态被覆盖到了,现在是全部有覆盖一遍。
//i表示的集合是i的子集。
dp[mask] = max(dp[mask],dp[mask^(<<i)]);
}
}
} int ans = , all = (<<) - ;
for(int i=;i<(<<);i++){
ans = max(ans, dp[i] + dp[all^i]);
}
printf("%d\n",ans);
}
return ;
}
cf1234-div3的更多相关文章
- Codeforces #550 (Div3) - G.Two Merged Sequences(dp / 贪心)
Problem Codeforces #550 (Div3) - G.Two Merged Sequences Time Limit: 2000 mSec Problem Description T ...
- codeforces-1144 (div3)
赛后经验:div3过于简单,以后不做了 A.存在以下情况即为NO 1.存在相同字母 2.最大字母-最小字母 != 字符串长度 #include <map> #include <set ...
- 12.27 cf div3 解题报告
12.27 cf div3 解题报告 wxy.wxy,带上分拉,全场做了个无脑小白 比赛场地 A: T1,跟着模拟就好了 B: sort一遍之后 去除的数一定是a[1]或者a[n] 比较去除谁小就输出 ...
- CodeForces 1029E div3
题目链接 第一道场上自己做出来的E题...虽然是div3,而且是原题... 当时做完ABC,D题没有思路就去怼E了,然后发现貌似原题? 事实上就是原题... 给个原题链接... [HNOI2003]消 ...
- CodeForces Round #527 (Div3) B. Teams Forming
http://codeforces.com/contest/1092/problem/B There are nn students in a university. The number of st ...
- 【赛时总结】◇赛时·V◇ Codeforces Round #486 Div3
◇赛时·V◇ Codeforces Round #486 Div3 又是一场历史悠久的比赛,老师拉着我回来考古了……为了不抢了后面一些同学的排名,我没有做A题 ◆ 题目&解析 [B题]Subs ...
- Codeforces Round #535 (Div. 3) [codeforces div3 难度测评]
hhhh感觉我真的太久没有接触过OI了 大约是前天听到JK他们约着一起刷codeforces,假期里觉得有些颓废的我忽然也心血来潮来看看题目 今天看codeforces才知道居然有div3了,感觉应该 ...
- CodeForces Round#480 div3 第2场
这次div3比上次多一道, 也加了半小时, 说区分不出1600以上的水平.(我也不清楚). A. Remove Duplicates 题意:给你一个数组,删除这个数组中相同的元素, 并且保留右边的元素 ...
- codeforces #579(div3)
codeforces #579(div3) A. Circle of Students 题意: 给定一个n个学生的编号,学生编号1~n,如果他们能够在不改变顺序的情况下按编号(无论是正序还是逆序,但不 ...
- CF598: div3解题报告
CF598:div3解题报告 A: Payment Without Change 思路: 按题意模拟即可. 代码: #include<bits/stdc++.h> using namesp ...
随机推荐
- js中的如何定位固定层的位置
需要获取一些HTML的对象的坐标来更灵活的设置目标层的坐标,这里可以通过用到document.body.scrollTop等属性,但是这些属性在xhtml的标准网页中或更简单的说就是带<!DOC ...
- 考试总结 模拟28(W)
心得: 状态极差,都怪放假,上一套的T3没改完,今天考试没有一点状态,开学恐惧症.(不恐惧作业或一调但还是很茫然) T1能A掉实在是意外,杂题T1没做过,可能是人品守恒,(丢了钱今天才发现以后一定锁柜 ...
- HDU - 1724 Ellipse 自适应辛普森模板
OJ 题解传送门 //Achen #include<algorithm> #include<iostream> #include<cstring> #include ...
- ML面试1000题系列(21-30)
本文总结ML面试常见的问题集 转载来源:https://blog.csdn.net/v_july_v/article/details/78121924 21.请简要说说EM算法. @tornadome ...
- Android——系统权限
Android是一个特权分隔的操作系统,每一个应用程序运行在不同的系统身份中(Linux的user ID和group ID).系统部分和不同的身份被隔离开来.因此,Linux隔离了应用程序(与其它程序 ...
- Codeforces Round #395 (Div. 2) A. Taymyr is calling you【数论/最小公倍数】
A. Taymyr is calling you time limit per test 1 second memory limit per test 256 megabytes input stan ...
- [LeetCode] Evaluate Reverse Polish Notation [2]
题目 Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, ...
- vue轮播图插件之vue-awesome-swiper
移动端轮播图插件,在使用iview图形界面插件中的carousel组件无法实现触摸滑动后,转而使用vue-awesome-swiper插件 1.npm安装 npm i vue-awesome-swip ...
- 前端与编译原理——用JS写一个JS解释器
说起编译原理,印象往往只停留在本科时那些枯燥的课程和晦涩的概念.作为前端开发者,编译原理似乎离我们很远,对它的理解很可能仅仅局限于"抽象语法树(AST)".但这仅仅是个开头而已.编 ...
- element-ui el-time-picker
获取时分秒时间 <el-time-picker is-range v-model="time" value-format="HH:mm:ss" range ...