当前位置:网站首页>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;
}
边栏推荐
- Heterogeneous graph neural network for recommendation system problems (ackrec, hfgn)
- Arrays in JS
- 小程序image 无法显示base64 图片 解决办法 有效
- JS中的数组
- OSPF综合实验
- Oil monkey script link
- Brpc source code analysis (VIII) -- detailed explanation of the basic class eventdispatcher
- [comparative learning] understanding the behavior of contractual loss (CVPR '21)
- 【AI4Code】《CodeBERT: A Pre-Trained Model for Programming and Natural Languages》 EMNLP 2020
- PHP curl post x-www-form-urlencoded
猜你喜欢

Multi-Label Image Classification(多标签图像分类)

LeetCode第303场周赛(20220724)

Transformer变体(Sparse Transformer,Longformer,Switch Transformer)

JS中的函数

Qin long, a technical expert of Alibaba cloud: a prerequisite for reliability assurance - how to carry out chaos engineering on the cloud
![[USB device design] - composite device, dual hid high-speed (64BYTE and 1024byte)](/img/ce/534834c53c72a53fd62ff72a1d3b39.png)
[USB device design] - composite device, dual hid high-speed (64BYTE and 1024byte)

OSPF综合实验

Risks in software testing phase

brpc源码解析(八)—— 基础类EventDispatcher详解

【AI4Code最终章】AlphaCode:《Competition-Level Code Generation with AlphaCode》(DeepMind)
随机推荐
【对比学习】Understanding the Behaviour of Contrastive Loss (CVPR‘21)
创新突破!亚信科技助力中国移动某省完成核心账务数据库自主可控改造
Brpc source code analysis (V) -- detailed explanation of basic resource pool
Attendance system based on w5500
[multimodal] hit: hierarchical transformer with momentum contract for video text retrieval iccv 2021
[imx6ull notes] - a preliminary exploration of the underlying driver of the kernel
【AI4Code】《CodeBERT: A Pre-Trained Model for Programming and Natural Languages》 EMNLP 2020
【AI4Code】《CoSQA: 20,000+ Web Queries for Code Search and Question Answering》 ACL 2021
【AI4Code】《Pythia: AI-assisted Code Completion System》(KDD 2019)
JS data types and mutual conversion
【AI4Code】CodeX:《Evaluating Large Language Models Trained on Code》(OpenAI)
LeetCode 50. Pow(x,n)
【GCN多模态RS】《Pre-training Representations of Multi-modal Multi-query E-commerce Search》 KDD 2022
油猴脚本链接
PHP curl post x-www-form-urlencoded
PHP curl post length required error setting header header
PHP one server sends pictures to another. Curl post file_ get_ Contents save pictures
Intelligent information retrieval(智能信息检索综述)
【AI4Code】《Unified Pre-training for Program Understanding and Generation》 NAACL 2021
JS中的函数