老年选手,做个签到就溜了。
现在才开始补题,cf分一直上不去。

目录

  • A. Madoka and Math Dad【构造】
  • B. Madoka and the Elegant Gift【连通块】
  • C. Madoka and Childish Pranks【构造】

A. Madoka and Math Dad【构造】


其实通过,样例你可以发现规律,要么121...要么2121... 就看余数是不是1了。

#include<bits/stdc++.h>
using namespace std;
int main(void)
{int t; cin>>t;while(t--){int n; cin>>n;if(n%3==1) {while(n>=3) cout<<"12",n-=3;cout<<n;}else {while(n>=3) cout<<"21",n-=3;if(n) cout<<n;}puts("");}return 0;
}

B. Madoka and the Elegant Gift【连通块】


就是判断每一个连通块是不是完美的矩形。
我的笨的方法,是直接暴力搜索,存一下左上角和右下角。
再二维前缀和求和。看结果和长乘宽的结果一样不一样。

#include<bits/stdc++.h>
using namespace std;
const int N=210;
int t,n,m,s[N][N];
int dx[4]={-1,0,0,1};
int dy[4]={0,-1,1,0};
char a[N][N];
int query(int x,int y,int xx,int yy)//(x,y)矩阵的左上角的坐标,(xx,yy)矩阵右下角的坐标
{int sum=s[xx][yy]-s[x-1][yy]-s[xx][y-1]+s[x-1][y-1];return sum;
}
void dfs(int x,int y,int& x1,int& y1,int& x2,int& y2)
{a[x][y]='0';x1=min(x1,x),x2=max(x2,x),y1=min(y1,y),y2=max(y2,y);for(int i=0;i<4;i++){int tempx=x+dx[i];int tempy=y+dy[i];if(tempx<=0||tempx>n||tempy<=0||tempy>m) continue;if(a[tempx][tempy]=='0') continue;dfs(tempx,tempy,x1,y1,x2,y2);}
}
int main(void)
{cin>>t;while(t--){memset(s,0,sizeof s);cin>>n>>m;for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)cin>>a[i][j],s[i][j]=a[i][j]-'0';for(int i=1;i<=n;i++)for(int j=1;j<=m;j++)s[i][j]+=s[i-1][j]+s[i][j-1]-s[i-1][j-1];bool flag=1;for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){if(a[i][j]=='1'){int x1=1e9,y1=1e9;int x2=-1e9,y2=-1e9;dfs(i,j,x1,y1,x2,y2);int temp=query(x1,y1,x2,y2);int temp1=(x2-x1+1)*(y2-y1+1);if(temp!=temp1) flag=0;}}}if(flag) puts("YES");else puts("NO");}return 0;
}

C. Madoka and Childish Pranks【构造】



先用上图从后往前构造,那么除了第一行,都可以完美的构造出来。
接下来就只看第一行。

上图,从右往左走。
md的因为用Clang++17交,一直T,后来才发现交错编译器了。

#include<bits/stdc++.h>
using namespace std;
const int N=210;
int t,n,m;
char a[N][N];
struct node{int a,b,c,d;};
int main(void)
{std::ios::sync_with_stdio(false);std::cin.tie(0);cin>>t;while(t--){cin>>n>>m;for(int i=0;i<n;i++) for(int j=0;j<m;j++) cin>>a[i][j];if(a[0][0]=='1'){cout<<"-1"<<'\n';continue;}vector<node>ve;for(int i=n-1;i>=1;i--)for(int j=0;j<m;j++) if(a[i][j]=='1') ve.push_back({i-1,j,i,j});for(int i=m-1;i>=1;i--)if(a[0][i]=='1') ve.push_back({0,i-1,0,i});cout<<ve.size()<<'\n';for(int i=0;i<ve.size();i++)cout<<ve[i].a+1<<" "<<ve[i].b+1<<" "<<ve[i].c+1<<" "<<ve[i].d+1<<'\n';}return 0;
}

Codeforces Round #777 (Div. 2)【未完结】相关推荐

  1. Codeforces Round #777 (Div. 2) 简训

    Codeforces Round #777 (Div. 2) 简训 导语 涉及的知识点 题目 A Madoka and Math Dad B Madoka and the Elegant Gift C ...

  2. Codeforces Round #486 (Div. 3)【完结】

    2022.3.2 题单地址:https://codeforces.com/contest/988 目录 A. Diverse Team[模拟] B. Substrings Sort[暴力枚举] C. ...

  3. Codeforces Round #777 (Div. 2) 题解

    Codeforces #777 题解 这次带上了大佬前来验题xs 公开大佬珍贵的代码资源供参考 TOC A.Madoka and Math Dad B.Madoka and the Elegant G ...

  4. Codeforces Round #498 (Div. 3)【完结】

    2022.3.6 题单地址:https://codeforces.com/contest/1006 目录 A. Adjacent Replacements B. Polycarp's Practice ...

  5. Codeforces Round #490 (Div. 3)【完结】

    2022.3.3 题单地址:https://codeforces.com/contest/999 目录 A. Mishka and Contest[模拟] B. Reversing Encryptio ...

  6. Codeforces Round #481 (Div. 3)【完结】

    2022.3.1 题目地址:https://codeforces.com/contest/978 目录 A. Remove Duplicates[模拟] B. File Name[贪心 / 双指针] ...

  7. Codeforces Round #479 (Div. 3)【完结】

    2022.2.28 开始复盘div3 题目链接:https://codeforces.com/contest/977 目录 A. Wrong Subtraction[签到模拟题] B. Two-gra ...

  8. 【记录CF】Codeforces Round #777 (Div. 2) A~C 题解

    目录 杂谈 A. Madoka and Math Dad B. Madoka and the Elegant Gift C. Madoka and Childish Pranks 杂谈 又是一场离谱掉 ...

  9. Codeforces Round #777 (Div. 2) (A-D题解)

    源代码:ACM/OpenjudgeNow/Codeforces at master · abmcar/ACM (github.com) 更好的阅读体验: 折跃坐标 碎碎念:不亏是俄罗斯场+二次元出题人 ...

最新文章

  1. execel公式 java工具,MyExcel(Excel Java工具包) v3.0.0下载
  2. SAP WMSD集成之Copy WM Quantity – Copy WM qty as delivery qty into delivery and PGI
  3. UE选择合适的小区进行驻留以后
  4. 模糊控制算法详细讲解
  5. linux监测node进程,通过node_exporter监控linux服务器一
  6. 使用异或运算交换两个任意类型变量
  7. 如何快速把音乐转成MP3格式
  8. Git安装Windows / Redhat / Ubuntu
  9. 用scikit-learn进行LDA降维
  10. 菜鸟学Linux 第031篇笔记 script,控制,while,function
  11. ubuntu设置apt-get永久使用http代理
  12. Stanford CS230深度学习(九)注意力机制和语音识别
  13. 20行 Python 代码爬取王者荣耀全英雄皮肤 | 原力计划
  14. 2020 Kyligence 面经
  15. ads pspice 导入_ADS中使用pspice模型
  16. 认知水平高下定义及提高认知水平的方法
  17. 雅虎邮箱pop服务器,使用Yahoo.com.cn的POP和SMTP
  18. 重磅!共掘千亿大数据市场 智领云2021年合作伙伴招募计划正式启动
  19. ECharts热力图指定颜色
  20. selenium调用IE浏览器

热门文章

  1. Py之moviepy:python库之moviepy的简介、安装、使用方法详细攻略
  2. 源码:我的关于NLP的博客(持续更新中...)
  3. C#事件与委托的区别
  4. LLBLGen update table with join
  5. webpack 3.1 升级webpack 4.0
  6. 2、cookie session token详解
  7. [LeetCode] 461. Hamming Distance
  8. C# 中的三个高级参数 params
  9. Maven之(二)Maven生命周期
  10. keepalived 安装和配置