Educational Codeforces Round 68 (Rated for Div. 2)补题
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)补题的更多相关文章
- Educational Codeforces Round 78 (Rated for Div. 2) --补题
链接 直接用数组记录每个字母的个数即可 #include<bits/stdc++.h> using namespace std; int a[26] = {0}; int b[26] = ...
- Educational Codeforces Round 74 (Rated for Div. 2)补题
慢慢来. 题目册 题目 A B C D E F G 状态 √ √ √ √ × ∅ ∅ //√,×,∅ 想法 A. Prime Subtraction res tp A 题意:给定\(x,y(x> ...
- Educational Codeforces Round 68 (Rated for Div. 2)---B
http://codeforces.com/contest/1194/problem/B /* */ # include <bits/stdc++.h> using namespace s ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- Educational Codeforces Round 76 (Rated for Div. 2) D题
题意: 给你n个关卡,每个关卡有一个怪物,怪物的攻击力为a[i],你有n个英雄,每个英雄有一个攻击力,和疲劳值,只要英雄的攻击力比怪物的高就算打过了,同时疲劳减一,一天只能出战一个英雄,一个英雄可以打 ...
随机推荐
- 1.3 JAVA规范以及基础语法(if条件和循环)
一.规范以及运算符 1.命名规则 类名大驼峰规则方法名.变量名小驼峰原则常量大写.下划线分开见名释义.不与关键字冲突 关键字链接:https://www.runoob.com/java/java-ba ...
- python之json读写
#将字典转json并写入文件 import json i=3 j=5 a={'a':i,'b':j} js=json.dumps(a) print(js) with open("/Users ...
- 预处理、const、static与sizeof-C++中const有什么作用(至少说出3个)
1:作用如下: (1)const用于定义常量:const定义的常量编译器可以对其进行数据静态类型安全检查. (2)const修饰函数形式的参数:当输入参数为用户自定义类型和抽象数据类型时,应该将“值传 ...
- Winform运行外部控制台程序,并在程序结束后执行其他动作
ProcessStartInfo psi = new ProcessStartInfo(); psi.FileName = @"程序名"; psi.Arguments = @&qu ...
- 【SR汇总】基于深度学习方法
1.SRCNN.FSRCNN (Learning a Deep Convolutional Network for Image Super-Resolution, ECCV2014) (Acceler ...
- jQuery常用操作部分总结
注意:$(“.xxx”) 类,一定要在前面加上点callback为完成后执行的函数名称隐藏显示:hide() show()淡入淡出:fadeIn() fadeOut() fadetoggl ...
- 数据分析 - seaborn 模块
seaborn 模块 简述 对 matplotlib 模块进行了二次封装, 底层依旧使用还是 matplotlib 的, 但是在此基础上增加了很多的易用性模板, 更加方便使用 引用使用 import ...
- PCD(点云数据)文件格式
博客转载自:http://www.pclcn.org/study/shownews.php?lang=cn&id=54 为什么用一种新的文件格式? PCD文件格式并非白费力气地做重复工作,现有 ...
- 关于java面试题
java的优点: Java是一种跨平台,适合于分布式计算环境的面向对象编程语言. 具体来说,它具有如下特性: 简单性.面向对象.分布式.解释型.可靠.安全.平台无关.可移植.高性能.多线程.动态性等.
- curl配置host
//要配置的虚拟域名$host = array( 'Host: demo-local.com' );$ch = curl_init();//要配置的ip 例如本机localhostcurl_setop ...