首页 > 其他分享 >Codeforces Round #236 (Div. 2) E - Strictly Positive Matrix

Codeforces Round #236 (Div. 2) E - Strictly Positive Matrix

时间:2023-02-06 00:44:05浏览次数:47  
标签:自乘 Matrix int Positive Strictly Codeforces

根据线性代数的知识可知邻接矩阵自乘相当于做floyed

把输入转化为01矩阵(显然>1的数和1是等价的)得到邻接矩阵

问是否存在k次后所有数都为正数等价为自乘k次后所有点两两可达

转化为图论,用tarjan缩点判断scc的数目是否只有一个,或者直接bitset优化folyed也可以

#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
const int N=2005;
int main(){
    fastio;
    bitset<N>f[N];
    int n;
    cin>>n;
    for(int _=1;_<=n;_++)
     for(int __=1;__<=n;__++){
         int x;cin>>x;
         f[_][__]=(x>0);
     }
    for(int i=1;i<=n;i++)
     for(int j=1;j<=n;j++)
      if(f[j][i]) f[j]|=f[i];
    
    for(int i=1;i<=n;i++){
        if(f[i].count()!=n) return puts("NO"),0; 
    }
    puts("YES");
}

 

标签:自乘,Matrix,int,Positive,Strictly,Codeforces
From: https://www.cnblogs.com/liyishui2003/p/17094266.html

相关文章

  • Disconnect Path in a Binary Matrix by at Most One Flip
    DisconnectPathinaBinaryMatrixbyatMostOneFlipYouaregivena0-indexed $m\timesn$binary matrix grid .Youcanmovefromacell (row,col) to......
  • Educational Codeforces Round 141:B. Matrix of Differences
    一、来源:Problem-B-Codeforces二、题面三、思路我们先从一维思考如何构造尽可能多的数值差。以n=2为例,此时有1,2,3,4数,其中构成差值为3的方案有一个1,4,构成差值......
  • matrix-tree 的一个推论
    本文作者的线性代数水平还很低,如果有什么更简单的方法请告诉TA。结论:对于一张无向图\(G\),设其Laplace矩阵为\(A\),而\(A\)的特征值分别为\(\lambda_1,\lambda_2,\l......
  • Codeforces 1316 D. Nash Matrix(dfs)
    题意:给出一个的棋盘和每个棋盘位置最后能走到的位置,如果一直走不停下来就是,可以停下来就是走到的最后位置,让你输出每个位置的操作字符,上下左右和,停在此位置。我们先找......
  • [LeetCode]Spiral Matrix
    QuestionGivenamatrixofmxnelements(mrows,ncolumns),returnallelementsofthematrixinspiralorder.Forexample,Giventhefollowingmatrix:[[1......
  • vulnhub_matrix-breakout-2-morpheus
    前言靶机地址:matrix-breakout-2-morpheus攻击机:kali2022.3靶机:matrix-breakout-2-morpheus题目描述:这是《黑客帝国突围》系列的第二部,副标题为墨菲斯:1。它的主题是对......
  • vulnhub靶场-->MATRIX-BREAKOUT: 2 MORPHEUS
    靶机下载地址MATRIX-BREAKOUT:2MORPHEUS <点我下载开始打靶IP发现nmap扫描网段发现靶机ip:192.168.111.139端口发现对靶机进行常规端口扫描发现两个http端口......
  • [LeetCode] 2319. Check if Matrix Is X-Matrix
    Asquarematrixissaidtobean X-Matrix if both ofthefollowingconditionshold:Alltheelementsinthediagonalsofthematrixare non-zero.Alloth......
  • [LeetCode] 1329. Sort the Matrix Diagonally 将矩阵按对角线排序
    A matrixdiagonal isadiagonallineofcellsstartingfromsomecellineitherthetopmostroworleftmostcolumnandgoinginthebottom-rightdirectionu......
  • Kth Smallest Element in a Sorted Matrix
    classSolution{//14ms,fasterthan55.67%publicintkthSmallest(int[][]matrix,intk){intm=matrix.le......