【无标题】

Recently, lzd has been learning two-view correspondences and geometry using order-aware network, which is a neural network that infers the probabilities of correspondences being inliers and regresses the relative pose encoded by the essential matrix. The order-aware network contains three novel operations: differentiable pooling layer(a permutation-invariant methods to cluster nodes in a learnable manner and capture the local context), order-aware differentiable unpooling layer(to upsample the coarsened feature maps and build a hierarchical architecture), and order-aware filtering block(to capture the global context with spatial connections). Since the order-aware network achieved the state-of-the-art(SOTA) performance, lzd considers it a good methods and want to share a problem, which is relevant to one of the operation mentioned above, for you to solve.

Shortly, the problem can be refined as:

You are given a matrix A with the shape of n×m and a matrix B with the shape of m×m. You can swap the arbitrary(任意) two rows of A and you can do this operation arbitrary times(possibly, 0 times).

Now, the question is that is it possible to make B=AT×A, where the AT stands for the transpose(转置) of matrix A and the "××" stands for the multiplication between two matrix.

Input

The first line consists of two integers n,m(1≤n,m≤100), describing the shape of A and B.

In the following n lines, each line contains m intergers Ai,j​(0≤Ai,j​≤106), denoting the matrix A.

In the following m lines, each line contains m intergers Bi,j​(0≤Bi,j​≤1015), denoting the matrix B

Output

Output a line containing a string. Output "YES"(without quotes) or "NO"(without quotes), denonting is it possible for you to make B=AT×A.

Sample 1

InputcopyOutputcopy
6 6
1 1 4 5 1 4
1 1 4 5 1 4
1 1 4 5 1 4
1 1 4 5 1 4
1 1 4 5 1 4
1 1 4 5 1 4
6 6 24 30 6 24
6 6 24 30 6 24
24 24 96 120 24 96
30 30 120 150 30 120
6 6 24 30 6 24
24 24 96 120 24 96
YES

Sample 2

InputcopyOutputcopy
1 4
1 2 3 4
1 2 3 114514
2 4 6 8
3 6 9 12
4 8 12 16

 

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
using namespace std;
#define int long long
typedef pair<int,int>PII;
constexpr int N=105;
int a[N][N];
int b[N][N];
signed main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); 
   int n,m;
   cin>>n>>m;
   for(int i=1;i<=n;i++){
       for(int j=1;j<=m;j++){
           cin>>a[i][j];
       }
   }
    bool st=false;
    for(int i=1;i<=m;i++){
        for(int j=1;j<=m;j++){
            cin>>b[i][j];
            for(int k=1;k<=n;k++){
                b[i][j]-=a[k][i]*a[k][j];
            }
            if(b[i][j]) st= true;
        }
    }
    if(st) cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
    return 0;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

q619718

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值