Proving Equivalences
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3093 Accepted Submission(s): 1162
Let A be an n × n matrix. Prove that the following statements are equivalent:
1. A is invertible.
2. Ax = b has exactly one solution for every n × 1 matrix b.
3. Ax = b is consistent for every n × 1 matrix b.
4. Ax = 0 has only the trivial solution x = 0.
The typical way to solve such an exercise is to show a series of implications. For instance, one can proceed by showing that (a) implies (b), that (b) implies (c), that (c) implies (d), and finally that (d) implies (a). These four implications show that the four statements are equivalent.
Another way would be to show that (a) is equivalent to (b) (by proving that (a) implies (b) and that (b) implies (a)), that (b) is equivalent to (c), and that (c) is equivalent to (d). However, this way requires proving six implications, which is clearly a lot more work than just proving four implications!
I have been given some similar tasks, and have already started proving some implications. Now I wonder, how many more implications do I have to prove? Can you help me determine this?
* One line containing two integers n (1 ≤ n ≤ 20000) and m (0 ≤ m ≤ 50000): the number of statements and the number of implications that have already been proved.
* m lines with two integers s1 and s2 (1 ≤ s1, s2 ≤ n and s1 ≠ s2) each, indicating that it has been proved that statement s1 implies statement s2.
* One line with the minimum number of additional implications that need to be proved in order to prove that all statements are equivalent.
2 4 0 3 2 1 2 1 3
4 2
将每个联通分量当成一个点,之后成了一个DAG(有向无环图)
s1=入度为0的点,s2=出度为0的点,然后取s1,s2的最大值就行
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <queue>
#include <cstdlib>
#include <string>
#include <set>
#include<stack>
using namespace std;
const int N=20010;
int b[N*3],dfn[N],lowlink[N],num[N];
int in[N],out[N];
bool instack[N];
vector<int> g[N];
stack<int> s;
int sign;
int ans;
int n,m;
void init()
{
for(int i=0;i<N;i++)
g[i].clear();
memset(dfn,0,sizeof(dfn));
memset(lowlink,0,sizeof(lowlink));
memset(b,0,sizeof(b));
memset(num,0,sizeof(num));
memset(instack,0,sizeof(instack));
}
void add_edge(int a,int b)
{
g[a].push_back(b);
return;
}
void tarjan(int u)
{
//cout<<"in"<<endl;
dfn[u]=lowlink[u]=sign;
sign++;
s.push(u);
instack[u]=true;
for(int i=0;i<g[u].size();i++)
{
int x=g[u][i];
if(!dfn[x])
{
tarjan(x);
lowlink[u]=min(lowlink[u],lowlink[x]);
}
else if(instack[x])
lowlink[u]=min(lowlink[u],dfn[x]);
}
if(dfn[u]==lowlink[u])
{
//cout<<"no"<<endl;
int t=-1;
ans++;
while(t!=u)
{
t=s.top();s.pop();
instack[t]=false;
num[t]=ans;
}
}
//cout<<"yes"<<endl;
}
int solve()
{
if(ans==1)
return 0;
// cout<<num[1]<<num[2]<<num[3]<<endl;
memset(in,0,sizeof(in));
memset(out,0,sizeof(out));
//cout<<"n="<<n<<endl;
for(int i=1;i<=n;i++)
{
for(int j=0;j<g[i].size();j++)
{
int x=g[i][j];
if(num[i]!=num[x])
{
//cout<<i<<" "<<x<<endl;
out[num[i]]++;
in[num[x]]++;
}
}
}
int s1=0,s2=0;
//cout<<"ans="<<ans<<endl;
//cout<<in[1]<<in[2]<<in[3]<<endl;
for(int i=1;i<=ans;i++)
{
if(in[i]==0) s1++;
if(out[i]==0) s2++;
}
return max(s1,s2);
}
int main()
{
int ca;
scanf("%d",&ca);
while(ca--)
{
scanf("%d%d",&n,&m);
init();
for(int i=0;i<m;i++)
{
int aa,bb;
scanf("%d%d",&aa,&bb);
add_edge(aa,bb);
}
//cout<<"yes"<<endl;
sign=1;ans=0;
for(int i=1;i<=n;i++)
{
//cout<<"no"<<endl;
if(!dfn[i])
tarjan(i);
}
//cout<<"ans="<<ans<<endl;
printf("%d\n",solve());
}
return 0;
}

本文探讨了线性代数中矩阵性质的等价性证明,通过一系列推导展示了不同命题之间的逻辑关联,旨在简化证明过程并加深对矩阵特性的理解。
2万+

被折叠的 条评论
为什么被折叠?



