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. 编译参数(-D)

    程序中可以使用#ifdef来控制输出信息 #include<stdio.h> #define DEBUG int main() { ; ; int sum = a + b; #ifdef ...

  2. 预处理、const、static与sizeof-使用const与#define的特点及区别

    1:#define只是用来做文本替换的.例如: #define PI 3.1415926 float angle; angle=*PI/; 那么,程序进行编译的时候,编译器会首先将“#define P ...

  3. Go Iris 中间件

    Iris 中间件 当我们在 iris 中讨论中间件时,我们讨论的是在HTTP请求生命周期中在主处理程序代码之前和/或之后的运行代码. 实现中间件功能,有下面这样两种方式: 方式一: 我们可以通过按顺序 ...

  4. 手把手教你在Linux系统下安装MongoDB

    1. 下载最新的stable版MongoDB [root@spirit-of-fire ~]# wget http://downloads.mongodb.org/linux/mongodb-linu ...

  5. [Mybatis]执行一句Sql返回一个List<String>

    在Mapper.xml如下书写SQL文,其中 resultType告知MyBatis返回的类型: <select id="selectExpiredDate" resultT ...

  6. 【Taro全实践】修改radio组件的大小

    需求是将radio选中后颜色改为橙色.大小改成合适大小. 1.改颜色 <Radio color='#FF7464'></Radio> 2.改大小 <Radio style ...

  7. PHP(面向对象)连接数据库,实现基本的增删改查

    https://blog.csdn.net/qq_37674858/article/details/78921485 --------------------- 本文来自 周子青 的CSDN 博客 , ...

  8. 008-ICMP协议(网络控制文协议)

    一.概述 ICMP是(Internet Control Message Protocol)Internet控制报文协议.它是TCP/IP协议簇的一个子协议,用于在IP主机.路由器之间传递控制消息.控制 ...

  9. Oracle 本地创建多个实例并创建多个监听(只能在服务端弄,不可在客户端)

    注意:监听必须在客户端创建,在客户端创建,会报错. 1.创建监听 通过 Net Configuration Assistant  创建监听,设置端口: 注意:此监听创建完后,服务列表里面并没有此服务的 ...

  10. [.NET] 一步步打造一个简单的 MVC 电商网站 - BooksStore(一) (转)

    http://www.cnblogs.com/liqingwen/p/6640861.html 一步步打造一个简单的 MVC 电商网站 - BooksStore(一) 本系列的 GitHub地址:ht ...