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个英雄,每个英雄有一个攻击力,和疲劳值,只要英雄的攻击力比怪物的高就算打过了,同时疲劳减一,一天只能出战一个英雄,一个英雄可以打 ...
随机推荐
- 第72节:Java中的数组
https://www.jianshu.com/p/9ad176caa5bc
- js scroll动画
知识点 1.window.scrollTo (x,y):可以把内容滚动到指定位置 scroll scroll:卷动意思(书卷) 从上到下移动 1.window.onscroll 窗口滚动事件 ...
- 【零基础】搞定zabbix安装
一.前言 最近想做服务器压力测试,测试软件找到了,突然发现还没有很好的办法监控服务器运行情况,之前用过zabbix,所以想到说要不就用zabbix来监控服务器运情况,不过这次就要好好研究下zabbix ...
- laravel如何从mysql数据库中随机抽取n条数据
laravel如何从mysql数据库中随机抽取n条数据 一.总结 一句话总结: inRandomOrder():$userQuestions=UserQuestion::where($map)-> ...
- 使用 docker 快速安装 oracle 11g
前言 我们在手动安装oracle数据库时,安装步骤纷繁复杂,耗时较长 在此介绍如何使用docker快速安装oracle 11g 一.docker 及其安装环境 操作系统: [root@centos7 ...
- 关于本电脑qt5.11+vs2017+opencv3.4的配置问题
本人想用qt5.11+vs2017+opencv3.4开发程序,配置了很久才成功,现在把配置后的环境变量记录一下,以供自己以后参考,同时也供大家参考. qt5.11+vs2017+opencv3.4的 ...
- curl获取远程页面
// 创建一个新cURL资源$ch = curl_init(); // 设置URL和相应的选项$options = array(CURLOPT_URL => 'http://www.w3csch ...
- Web实现前后端分离,前后端解耦
一.前言 ”前后端分离“已经成为互联网项目开发的业界标杆,通过Tomcat+Ngnix(也可以中间有个Node.js),有效地进行解耦.并且前后端分离会为以后的大型分布式架构.弹性计算架构.微服务架构 ...
- Linux系统管理_主题01 :初识Linux_1.6 用好帮助文档man
在 man 界面中,可以使用如下快捷键来进行操作: 上/下箭头 向上/下滚动一行 [Space] 向下翻一页 [Page Down] 向下翻一页 [Page Up] 向上翻一页 [ ...
- Go项目实战:打造高并发日志采集系统(五)
前情回顾 前文我们完成了如下功能1 根据配置文件启动多个协程监控日志,并启动协程监听配置文件.2 根据配置文件热更新,动态协调日志监控.3 编写测试代码,向文件中不断写入日志并备份日志,验证系统健壮性 ...