链接 : https://codeforces.com/contest/1365/problems

problem A

统计可用的行和列的最小值, 模2输出即可

/*
* Author: RoccoShi
* Time: 2020-06-07 22:35:02
*/ #include <bits/stdc++.h>
using namespace std; typedef long long ll; int vix[50];
int viy[50];
int cntx=0, cnty=0; int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
while(t--){
int m, n;
cin >> n >> m;
int x;
for(int i = 0; i < n; ++ i)
for(int j = 0; j < m; ++ j){
cin>>x;
if(x==1){
vix[i] = 1;
viy[j] = 1;
}
}
for(int i = 0; i < n; ++ i)
{
if(vix[i]==0) cntx++;
}
for(int i = 0; i < m; ++ i){
if(viy[i]==0) cnty++;
}
int ans = min(cntx,cnty) % 2;
if(ans==1)cout << "Ashish" <<endl;
else cout << "Vivek" <<endl;
memset(vix,0,sizeof(vix));
memset(viy,0,sizeof(viy));
cntx=0;cnty=0;
} return 0;
}

problem B

可以知道, 只要有0,1那么这个数组想换成啥样就换成啥样

如果全0 or 全1, 数组必须得是非递减

/*
* Author: RoccoShi
* Time: 2020-06-07 22:35:02
*/ #include <bits/stdc++.h>
using namespace std; typedef long long ll; int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
while(t--){
int n,a,b,tmp;
cin>>n;
int flag = 0;
for(int i=0;i<n;++i){
cin >> a;
if(i!=0)
if(a<tmp)
flag = 1;
tmp = a;
}
for(int i=0;i<n;++i){
cin >> b;
if(i!=0)
if(b!=tmp)
flag = 0;
tmp = b;
}
if(flag == 0)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}
return 0; }

problem C

固定其中一个数组不动, 另一个数组最多右移n-1次

用一个数组vis保存数组a的每个值的位置

vis[i]表示 : i在数组a中的位置为vis[i]

当输入数组b时, 直接用ans = vis[b[i]] - i ( 这个数在a的位置 - 这个数在b的位置 )

如果>=0, 则此数移动ans次可匹配

如果<0, 则此数移动n+ans次可匹配

用一个map装移动x次能匹配的数的个数, 最后遍历取最大值为答案

/*
* Author: RoccoShi
* Time: 2020-06-07 22:35:02
*/ #include <bits/stdc++.h>
using namespace std; typedef long long ll;
const int N = 4e5 + 5;
int a[N], b[N], vis[N];
int ans = 0;
map<int,int> mp; int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
for(int i = 0; i < n; ++i){
cin >> a[i];
vis[a[i]] = i;
}
for(int i = 0; i < n; ++i){
cin >> b[i];
ans = vis[b[i]] - i;
if(ans >= 0)
mp[ans]++;
else
mp[n+ans]++;
}
map<int,int>::iterator it;
ans = -1;
for(it = mp.begin(); it != mp.end(); ++it)
{
ans = max(ans, it->second);
}
cout << ans << endl;
return 0;
}

problem D

统计好人个数, 然后把坏人全封死, 再从终点往回dfs统计好人的个数, 如果好人全找到了, 就YES否则NO

/*
* Author: RoccoShi
* Time: 2020-06-07 22:35:02
*/ #include <bits/stdc++.h>
using namespace std; typedef long long ll;
char a[55][55];
int vis[55][55];
int m, n, ans; int dfs(int x,int y){
if(vis[x][y] || a[x][y]=='#')
return 0;
int ans = 0;
vis[x][y] = 1;
if(a[x][y] == 'G')
{
ans++;
}
ans = ans + dfs(x+1,y);
ans = ans + dfs(x-1,y);
ans = ans + dfs(x,y+1);
ans = ans + dfs(x,y-1);
return ans;
} int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
while(t--){
cin >> m >> n;
for(int i=0;i<=m+1;++i)
{
a[i][0] = '#';
a[i][n+1] = '#';
}
for(int j=0;j<=n+1;++j)
{
a[0][j] = '#';
a[m+1][j] = '#';
}
int cntG=0;
for(int i = 1; i <= m; ++i){
for(int j = 1; j <= n; ++j)
{
cin>>a[i][j];
if(a[i][j] == 'G') cntG++;
}
}
for(int i = 1; i <= m; ++i){
for(int j = 1; j <= n; ++j)
{
if(a[i][j]=='B'){
a[i][j-1]!='B'?a[i][j-1]='#':1;
a[i][j+1]!='B'?a[i][j+1]='#':1;
a[i+1][j]!='B'?a[i+1][j]='#':1;
a[i-1][j]!='B'?a[i-1][j]='#':1;
}
}
} ans = dfs(m,n);
if(ans == cntG)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
memset(vis,0,sizeof(vis));
}
return 0;
}

这次比赛只写了前2题, 后两题补的

如果说学到了什么, 那就是找通解不要瞎jier特判, 判到最后一堆bug还把人给判晕了

Codeforces Round #648 (Div. 2)的更多相关文章

  1. Codeforces Round #648 (Div. 2) E. Maximum Subsequence Value(鸽巢原理)

    题目链接:https://codeforces.com/problemset/problem/1365/E 题意 有 $n$ 个元素,定义大小为 $k$ 的集合值为 $\sum2^i$,其中,若集合内 ...

  2. Codeforces Round #648 (Div. 2) D. Solve The Maze

    这题犯了一个很严重的错误,bfs 应该在入队操作的同时标记访问,而不是每次只标记取出的队首元素. 题目链接:https://codeforces.com/contest/1365/problem/D ...

  3. Codeforces Round #648 (Div. 2) C. Rotation Matching

    题目链接:https://codeforces.com/contest/1365/problem/C 题意 有两个大小为 $n$ 的排列,可以循环左移或右移任意次,问最多有多少对同一值在同一位置. 题 ...

  4. Codeforces Round #648 (Div. 2) B. Trouble Sort

    一开始读错题了...想当然地认为只能相邻元素交换...(然后换了两种写法WA了4发,5分钟切A的优势荡然无存) 题目链接:https://codeforces.com/contest/1365/pro ...

  5. Codeforces Round #648 (Div. 2) A. Matrix Game

    题目链接:https://codeforces.com/contest/1365/problem/A 题意 给出一个 $n \times m$ 的网格,两人轮流选择一个所在行列没有 $1$ 的方块置为 ...

  6. Codeforces Round #648 (Div. 2) E. Maximum Subsequence Value 贪心

    题意:E.Maximum Subsequence Value 题意: 给你n 个元素,你挑选k个元素,那么这个 k 集合的值为 ∑2i,其中,若集合内至少有 max(1,k−2)个数二进制下第 i 位 ...

  7. Codeforces Round #648 (Div. 2) F. Swaps Again

    题目链接:F.Swaps Again 题意: 有两个长度为n的数组a和数组b,可以选择k(1<=k<=n/2)交换某一个数组的前缀k和后缀k,可以交换任意次数,看最后是否能使两个数组相等 ...

  8. Codeforces Round #366 (Div. 2) ABC

    Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...

  9. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

随机推荐

  1. F. Machine Learning 带修端点莫队

    F. Machine Learning time limit per test 4 seconds memory limit per test 512 megabytes input standard ...

  2. SOFA入门

    简介 scalable open financial architecture stack , 可扩展开放的金融架构栈: github: https://github.com/sofastack/so ...

  3. 一文带你学会基于SpringAop实现操作日志的记录

    前言 大家好,这里是经典鸡翅,今天给大家带来一篇基于SpringAop实现的操作日志记录的解决的方案.大家可能会说,切,操作日志记录这么简单的东西,老生常谈了.不! 网上的操作日志一般就是记录操作人, ...

  4. KNIME快速入门指南

    一.介绍  KNIME Analytics Platform是用于创建数据科学应用程序和服务的开源软件.KNIME直观,开放,不断整合新的开发,使人们可以理解数据,设计数据科学工作流程和可重用组件. ...

  5. JavaScript 实现 冒泡排序

        <script>         //数组排序(冒泡排序)         //冒泡排序是一种算法,把一系列的数据按照一定的循序进行排列显示(从小到大或从大到小)          ...

  6. Python编程思想(3):数字及其相关运算

    Python 提供了三种数值类型:int(整型),float(浮点型)和complex(复数). int:通常被称为整型或者整数,如200.299.10都属于整型: float:浮点数包含整数和小数部 ...

  7. [C#.NET拾遗补漏]01:字符串操作

    字符串操作在任意编程语言的日常编程中都随处可见,今天来汇总一下 C# 中关于字符串的一些你可能遗忘或遗漏的知识点. 逐字字符串 在普通字符串中,反斜杠字符是转义字符.而在逐字字符串(Verbatim ...

  8. Liunx下使用wine容器实现跨平台使用软件

    首先在Liunx中使用QQ,网易云音乐,等这些软件是很痛苦的,某些软件可能会有Liunx版本,但是像腾讯QQ早年前也提供过Linux版本,后来就下架了!!! 这里我以ubuntu18.04版本为列,讲 ...

  9. Java并发编程 (九) 线程调度-线程池

    个人博客网:https://wushaopei.github.io/    (你想要这里多有) 声明:实际上,在开发中并不会普遍的使用Thread,因为它具有一些弊端,对并发性能的影响比较大,如下: ...

  10. Java实现 蓝桥杯 算法提高 字符串匹配

    试题 算法提高 字符串匹配 问题描述 给出一个字符串和多行文字,在这些文字中找到字符串出现的那些行.你的程序还需支持大小写敏感选项:当选项打开时,表示同一个字母的大写和小写看作不同的字符:当选项关闭时 ...