Codeforces Round #546 C. Nastya Is Transposing Matrices
题面:
题目描述:
题目分析:




1 #include <stdio.h>
2 #include <vector>
3 #include <algorithm>
4 using namespace std;
5 int n, m, A, B;
6 vector<int> a[1005], b[1005];
7
8 int main(){
9 scanf("%d%d", &n, &m);
10 for(int i = 0; i < n; i++){
11 for(int j = 0; j < m; j++){
12 scanf("%d", &A);
13 a[i+j].push_back(A); //将行列之和相同的元素加入到同一组
14 }
15 }
16 for(int i = 0; i < n; i++){
17 for(int j = 0; j < m; j++){
18 scanf("%d", &B);
19 b[i+j].push_back(B);
20 }
21 }
22
23 for(int i = 0; i < n+m; i++){
24 //排序,方便下面判断
25 sort(a[i].begin(), a[i].end());
26 sort(b[i].begin(), b[i].end());
27
28 if(a[i] != b[i]){ //判断:行列之和相同时,两个矩阵包含的元素是否相同
29 printf("NO\n");
30 return 0;
31 }
32 }
33 printf("YES\n");
34 return 0;
35 }
Codeforces Round #546 C. Nastya Is Transposing Matrices的更多相关文章
- Codeforces Round #546 (Div. 2) C. Nastya Is Transposing Matrices
C. Nastya Is Transposing Matrices time limit per test 1 second memory limit per test 256 megabytes i ...
- Codeforces Round #546 (Div. 2) 题解
Codeforces Round #546 (Div. 2) 题目链接:https://codeforces.com/contest/1136 A. Nastya Is Reading a Book ...
- Codeforces 1136C - Nastya Is Transposing Matrices
题目链接:https://codeforces.com/problemset/problem/1136/C 题意: 给出 $n \times m$ 的矩阵 $A,B$,你可以对其中任意某个 $k \t ...
- Codeforces Round #546 (Div. 2) B. Nastya Is Playing Computer Games
链接:https://codeforces.com/contest/1136/problem/B 题意: 有n个井盖,每个井盖上有一个小石头. 给出n和k,k表示刚开始在第k个井盖上方. 有三种操作, ...
- Codeforces Round #546 (Div. 2) A. Nastya Is Reading a Book
链接:https://codeforces.com/contest/1136/problem/A 题意: 给n个区间,每个区间范围不超过100,n不超过100. 给一个位置k,1-(k-1)是遍历过的 ...
- Codeforces Round #546 (Div. 2)-D - Nastya Is Buying Lunch
这道题,神仙贪心题... 题意就是我给出数的顺序,并给出多个交换,每个只能用于相邻交换,问最后一个元素,最多能往前交换多少步. 我们考虑这样一个问题,如果一个这数和a[n]发生交换,那么这个数作为后面 ...
- codeforces#1136 C. Nastya Is Transposing Matrices(找规律)
题意:给出两个n*m的矩阵,每次操作可以让一个正方形矩阵行列交换.问,在无限次操作下,第一个矩阵能否变成第二个矩阵 分析:先把操作限定在2*2的矩阵中.这样对角线上的元素就可以随意交换.也就是说,如果 ...
- Codeforces Round #546 (Div. 2) E - Nastya Hasn't Written a Legend
这题是一个贼搞人的线段树 线段树维护的是 区间和a[i - j] 首先对于update的位置可以二分查找 其次update时候的lazy比较技巧 比如更新的是 l-r段,增加的是c 那么这段的值为: ...
- Nastya Hasn't Written a Legend(Codeforces Round #546 (Div. 2)E+线段树)
题目链接 传送门 题面 题意 给你一个\(a\)数组和一个\(k\)数组,进行\(q\)次操作,操作分为两种: 将\(a_i\)增加\(x\),此时如果\(a_{i+1}<a_i+k_i\),那 ...
随机推荐
- Linux添加系统调用
Linux添加系统调用 1 概述 通常添加系统调用有两种方案: * 重新编译内核 * 添加内核模块 此处我们采用重新编译内核的方式增加系统调用. 实验环境:X86_64 GNU/Linux 4.15. ...
- bitbar 网站攻击实验
实验环境 https://github.com/TouwaErioH/security/tree/master/web1 Windows10 Oracle VM VirtualBox Ubuntu16 ...
- hdu 5874
On an isolated island, lived some dwarves. A king (not a dwarf) ruled the island and the seas nearby ...
- Linux Schedule Cron All In One
Linux Schedule Cron All In One 定时任务 / 定时器 GitHub Actions Scheduled events Cron syntax has five field ...
- Flutter CodePen challenges
Flutter CodePen challenges 挑战赛 https://mp.weixin.qq.com/s/qIYokWN9SVgr-F7YxbJuOQ CodePen Flutter 编辑器 ...
- Node.js Learning Paths
Node.js Learning Paths Node.js in Action Node.js Expert situations / scenario Restful API OAuth 2.0 ...
- BattleBots
BattleBots 搏茨大战 https://battlebots.com/ BiteForce https://www.youtube.com/watch?v=06lyUXuQT_Y xgqfrm ...
- skills share & free videos
skills share & free videos 技术分享 & 免费视频 https://www.infoq.cn/video/list WebAssembly https://w ...
- svg insert shape string bug
svg insert shape string bug not support custom areaProps attributes ??? const svg = document.querySe ...
- uniapp 发起网络请求
推荐下我写的uni-http 创建http-config.js import Vue from 'vue' const BASE_URL = 'http://xxx.com'; if (process ...