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. 日期与时间(C/C++)

    C++继承了C语言用于日期和时间操作的结构和函数,使用之前程序要引用<ctime>头文件 有四个与时间相关的类型:clock_t.time_t.size_t.和tm.类型clock_t.s ...

  2. Java基础_类的加载机制和反射

    类的使用分为三个步骤: 类的加载->类的连接->类的初始化 一.类的加载 当程序运行的时候,系统会首先把我们要使用的Java类加载到内存中.这里加载的是编译后的.class文件 每个类加载 ...

  3. 【模板】强连通分量和tarjan算法

    看了好久才终于明白了这个算法..复杂度是O(n+m). 我觉得这个算法不是很好理解,但是看懂了以后还是觉得听巧妙的. 下面给出模板代码和三组简单数据帮助理解. 代码如下: #include <s ...

  4. django快速实现完整登录系统,把登陆注册串在一起并增加cookie(六)

    1.使用之前创建的项目和应用  mysite3 account 2.使用之前的数据库构造 class User(models.Model): username=models.CharField(max ...

  5. vue中解决three.js出现内存泄漏丢失上下文问题

    在跳转页面时添加以上代码即可. 在spa项目中,跳转页面并不会清楚已经创建的webgl实例,需要手动清楚.

  6. HTTP之简析

    1. 简介 HTTP 协议是 Hyper Text Transfer Protocol(超文本传传输协议)的缩写,是用于从万维网服务器传输超文本到本地浏览器的传送协议.HTTP 通常架构在 TCP 传 ...

  7. 使用 usb 调试的时候,连接上电脑没反应

    使用 usb 调试的时候,连接上电脑没反应 原因: 手机上没有信任本计算机的授权,请在手机上信任该授权 解决方法: 原因就是手机上会有一个弹话框,让我们信任该计算机,我们才可以进行 usb调试 我们的 ...

  8. JS 省市联动 ajax

    省市联动 //省市联动     $('.locationCode').change(function () {         var val = $(this).val();         if ...

  9. linux服务之memcached

    http://www.runoob.com/memcached/memcached-cas.html https://github.com/memcached/memcached/blob/maste ...

  10. php连接数据库的两种方式- 面向过程 面向对象

    php连接数据库的两种方式- 面向过程 面向对象   一.面向对象1. 链接数据库$conn = @new mysqli("127.0.0.1","root", ...