当前位置:网站首页>Mirror Grid
Mirror Grid
2022-07-25 11:14:00 【梦中醉卧惊起】
Mirror Grid
题意:
给定一个n * n的矩形,将其旋转90°,180°,270°后保持不变.问需要最少多少步可以完成.
思路:
由题意可知这个矩阵必须是中心对称图形,所以遍历这个矩形的每一层,查看每次0多还是1多即可
重点 : 遍历矩阵
AC代码:
#include <iostream>
#include <algorithm>
using namespace std;
int a[105][105];
int main(){
int t;cin >> t;
while(t --){
int n;cin >> n;
for(int i = 1;i <= n;i ++)
for(int j = 1;j <= n;j ++){
char x;cin >> x;
a[i][j] = x - '0';
}
int ans = 0;
for(int i = 1;i <= (n + 1) / 2;i ++){
for(int j = 1;j <= n / 2;j ++){
int x = a[i][j] + a[j][n-i+1] + a[n-i+1][n-j+1] + a[n-j+1][i];
ans += min(4 - x,x);
}
}
cout << ans << endl;
}
return 0;
}
边栏推荐
- 硬件连接服务器 tcp通讯协议 gateway
- selenium使用———安装、测试
- JS流程控制
- [RS sampling] a gain tuning dynamic negative sampler for recommendation (WWW 2022)
- Application of comparative learning (lcgnn, videomoco, graphcl, XMC GaN)
- OSPF综合实验
- brpc源码解析(八)—— 基础类EventDispatcher详解
- PHP curl post x-www-form-urlencoded
- 【多模态】《TransRec: Learning Transferable Recommendation from Mixture-of-Modality Feedback》 Arxiv‘22
- 【高并发】高并发场景下一种比读写锁更快的锁,看完我彻底折服了!!(建议收藏)
猜你喜欢

Management of software defects

Experimental reproduction of image classification (reasoning only) based on caffe resnet-50 network

【AI4Code】《Pythia: AI-assisted Code Completion System》(KDD 2019)

PHP curl post length required error setting header header

30 sets of Chinese style ppt/ creative ppt templates

Transformer变体(Routing Transformer,Linformer,Big Bird)

【GCN-RS】MCL: Mixed-Centric Loss for Collaborative Filtering (WWW‘22)
![[multimodal] transferrec: learning transferable recommendation from texture of modality feedback arXiv '22](/img/02/5f24b4af44f2f9933ce0f031d69a19.png)
[multimodal] transferrec: learning transferable recommendation from texture of modality feedback arXiv '22

30套中国风PPT/创意PPT模板

JS中的函数
随机推荐
Solved files' name is invalid or doors not exist (1205)
Qin long, a technical expert of Alibaba cloud: a prerequisite for reliability assurance - how to carry out chaos engineering on the cloud
什么是全局事件总线?
OSPF综合实验
brpc源码解析(四)—— Bthread机制
已解决The JSP specification requires that an attribute name is preceded by whitespace
JS作用域以及预解析
brpc源码解析(六)—— 基础类socket详解
【GCN-RS】MCL: Mixed-Centric Loss for Collaborative Filtering (WWW‘22)
Power BI----这几个技能让报表更具“逼格“
Meta learning (meta learning and small sample learning)
pycharm连接远程服务器ssh -u 报错:No such file or directory
【AI4Code】《Contrastive Code Representation Learning》 (EMNLP 2021)
【无标题】
The JSP specification requires that an attribute name is preceded by whitespace
【GCN-RS】Region or Global? A Principle for Negative Sampling in Graph-based Recommendation (TKDE‘22)
JS scope and pre parsing
[high concurrency] Why is the simpledateformat class thread safe? (six solutions are attached, which are recommended for collection)
JS中的数组
LeetCode第303场周赛(20220724)