A. Remove a Progression

签到题,易知删去的为奇数,剩下的是正偶数数列。

#include<iostream>
using namespace std; int T;
int n,x; int main(){
cin>>T;
while(T--){
cin>>n>>x;
cout<<x * 2<<endl;
}
return 0;
}

  

B. Yet Another Crosses Problem

n*m存在上界,以一维数组储存二维数组。统计各个行(列)的白块数量,找出其中数量最少的行(列)(注:不一定只有一行(列)的白块最少)。输出结果为最小行数与最小列数之和。

仍遍历满足上述条件的行和列的交点,若其为白块,则输出结果需减去重复点。

#include<iostream>
#include<algorithm>
using namespace std;
const int L = 400000+500;
int q,n,m;
char M[L];
int ans;
int NN[L],NM[L]; int f(){
for(int i =0;i<n;++i) NN[i] = 0;
for(int i = 0;i<m;++i) NM[i] = 0;
for(int i = 0;i<n;++i)
for(int j = 0;j<m;++j)
if(M[i*m+j] == '.') NN[i]++;
for(int j = 0;j<m;++j)
for(int i = 0;i<n;++i)
if(M[i*m+j] == '.') NM[j]++;
int minn = NN[0];
int minm = NM[0];
for(int i =0;i<n;++i) minn = min(minn,NN[i]);
for(int i =0;i<m;++i) minm = min(minm,NM[i]);
int ans = minn + minm;
for(int i = 0;i<n;++i)
for(int j = 0;j<m;++j)
if(NN[i] == minn&&NM[j] == minm)
if(M[i*m+j] == '.') return ans-1; return ans;
}
int main(){
cin>>q;
while(q--){
cin>>n>>m;
for(int i =0;i<n;++i)
cin>>(M + i*m);
ans = f();
cout<<ans<<endl;
}
return 0;
}

 

C. From S To T

通过判断串s 是否由串t 退化而来,初步确定答案。

之后判断串t 删去与串s 对应的字符后是否可以由串p 的元素所构成。

#include<iostream>
#include<algorithm>
#include<cstring>
#include<queue>
using namespace std;
const int L = +;
int q;
char s[L],t[L],p[L];
int T[L];
int al[];
int main(){
cin>>q;
while(q--){
cin>>s>>t>>p;
bool ans = true;
for(int i =;i<;++i) al[i] = ;
for(int i =;i<L;++i) T[i] = ;
for(int i =;p[i]!='\0';++i)
al[p[i] - 'a']++;
int pj = ;
bool flag = false;
for(int i = ;s[i]!='\0';++i){
flag = false;
for(int j = pj;j<strlen(t);++j){
if(s[i] == t[j]){
T[j] = ;
flag = true;
pj = j+;
break;
}
}
if(!flag){
ans = false;
break;
}
}
if(!ans){
cout<<"NO"<<endl;
continue;
}
for(int i = strlen(t);i>=;--i){
if(T[i] == ){
for(int j = i;t[j]!='\0';++j)
t[j] = t[j+];
}
}
for(int i = ;t[i]!='\0';++i){
if(al[t[i] - 'a'] > ){
al[t[i] - 'a']--;
}
else{
ans = false;
break;
}
}
if(ans)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
return ;
}

D. 1-2-K Game

博弈,找规律。情况可分为

①n < k

②n>=k 且 k%3=0

③n>=k 且 k%3≠0

对情况①③,若n%3=0先手必败,反之必胜。

对情况② 令 n = n%(k+1) 条件一:若n =k,先手必胜 ;条件二:若n%3==0,先手必败,反之必胜。条件一优先级高于条件二。

#include<iostream>
using namespace std; int T;
int n,k; int main(){
cin>>T;
while(T--){
cin>>n>>k;
if( n < k ){
n%=;
if(n == ) cout<<"Bob"<<endl;
else cout<<"Alice"<<endl;
}
else{
if(k % == ){
n %= k + ;
if(n == k)
cout<<"Alice"<<endl;
else{
n%=;
if(n == ) cout<<"Bob"<<endl;
else cout<<"Alice"<<endl;
}
}
else{
n%=;
if(n == ) cout<<"Bob"<<endl;
else cout<<"Alice"<<endl;
}
}
}
return ;
}

Educational Codeforces Round 68 (Rated for Div. 2)补题的更多相关文章

  1. Educational Codeforces Round 78 (Rated for Div. 2) --补题

    链接 直接用数组记录每个字母的个数即可 #include<bits/stdc++.h> using namespace std; int a[26] = {0}; int b[26] = ...

  2. Educational Codeforces Round 74 (Rated for Div. 2)补题

    慢慢来. 题目册 题目 A B C D E F G 状态 √ √ √ √ × ∅ ∅ //√,×,∅ 想法 A. Prime Subtraction res tp A 题意:给定\(x,y(x> ...

  3. Educational Codeforces Round 68 (Rated for Div. 2)---B

    http://codeforces.com/contest/1194/problem/B /* */ # include <bits/stdc++.h> using namespace s ...

  4. Educational Codeforces Round 68 (Rated for Div. 2) C. From S To T (字符串处理)

    C. From S To T time limit per test1 second memory limit per test256 megabytes inputstandard input ou ...

  5. Educational Codeforces Round 68 (Rated for Div. 2) D. 1-2-K Game (博弈, sg函数,规律)

    D. 1-2-K Game time limit per test2 seconds memory limit per test256 megabytes inputstandard input ou ...

  6. Educational Codeforces Round 68 (Rated for Div. 2)D(SG函数打表,找规律)

    #include<bits/stdc++.h>using namespace std;int sg[1007];int main(){ int t; cin>>t; while ...

  7. Educational Codeforces Round 68 (Rated for Div. 2)-D. 1-2-K Game

    output standard output Alice and Bob play a game. There is a paper strip which is divided into n + 1 ...

  8. Educational Codeforces Round 68 (Rated for Div. 2)-C-From S To T

    You are given three strings ss, tt and pp consisting of lowercase Latin letters. You may perform any ...

  9. Educational Codeforces Round 76 (Rated for Div. 2) D题

    题意: 给你n个关卡,每个关卡有一个怪物,怪物的攻击力为a[i],你有n个英雄,每个英雄有一个攻击力,和疲劳值,只要英雄的攻击力比怪物的高就算打过了,同时疲劳减一,一天只能出战一个英雄,一个英雄可以打 ...

随机推荐

  1. 【线性代数】2-6:三角矩阵( $A=LU$ and $A=LDU$ )

    title: [线性代数]2-6:三角矩阵( A=LUA=LUA=LU and A=LDUA=LDUA=LDU ) toc: true categories: Mathematic Linear Al ...

  2. [bat]只更新svn部分文件夹

    游戏工程里的sdk文件夹,经常被svn认定为有毒文件. 后来关了权限之后,已拉取过的sdk文件夹还是会拉下来. 网上找了个方法,bat文件只更新部分文件. TortoiseProc /command: ...

  3. codeforces#1167F. Scalar Queries(树状数组+求贡献)

    题目链接: https://codeforces.com/contest/1167/problem/F 题意: 给出长度为$n$的数组,初始每个元素为$a_i$ 定义:$f(l, r)$为,重排$l$ ...

  4. AT3576 Popping Balls

    AT3576 Popping Balls 好题!一种以前没怎么见过的思路! %%ywy 以什么方式,什么位置统计本质不同的方案,才能不重不漏是处理所有计数问题的主心骨. 本题难以容斥.难以DP. 所以 ...

  5. 【洛谷1345】 [USACO5.4]奶牛的电信(最小割)

    传送门 洛谷 Solution emmm,直接对于每一个点拆点就好了. 然后边连Inf,点连1,跑最小割就是答案. 代码实现 #include<bits/stdc++.h> using n ...

  6. Tomcat配置 https SSL证书

    HTTP与HTTPS的区别:HTTP协议传输的数据都是未加密的,也就是明文的,因此使用HTTP协议传输隐私信息非常不安全,为了保证这些隐私数据能加密传输,于是网景公司设计了SSL(Secure Soc ...

  7. 转载 AMI方案和Insyde方案

    闲来无事回头看看,自毕业以来一直都在BIOS这个行业打转,目前的各种新闻来看全球的IT行业都似乎不太景气,PC出货量一泻千里,想要有所转机看起来不是一天两天的事情,想来无事来看看做过的几个UEFI B ...

  8. Android Dalvik、ART及APK编译过程

    0.1 先对Dalvik以及ART做简单介绍: 什么是Dalvik: Dalvik是Google公司自己设计用于Android平台的Java虚拟机.dex格式是专为Dalvik应用设计的一种压缩格式, ...

  9. springboot 静态资源访问,和文件上传 ,以及路径问题

    springboot 静态资源访问: 这是springboot 默认的静态资源访问路径  访问顺序依次从前到后(http://localhost:8080/bb.jpg) spring.resourc ...

  10. easuUI之datebox日期选择框

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <hea ...