8.19
This commit is contained in:
parent
e7bb29c6ac
commit
5289827262
@ -11,4 +11,4 @@ ans=ans/2+1;(i<=j,
|
||||
### 易错点
|
||||
*
|
||||
### 工具箱
|
||||
*
|
||||
* https://www.cnblogs.com/shentr/p/5285407.html
|
BIN
8.18.威尔逊定理/G题-赵炜铭.mp4
Normal file
BIN
8.18.威尔逊定理/G题-赵炜铭.mp4
Normal file
Binary file not shown.
BIN
8.18.威尔逊定理/G题-郑宇飞.mp4
Normal file
BIN
8.18.威尔逊定理/G题-郑宇飞.mp4
Normal file
Binary file not shown.
BIN
8.18.威尔逊定理/M题-崔东旭1.mp4
Normal file
BIN
8.18.威尔逊定理/M题-崔东旭1.mp4
Normal file
Binary file not shown.
BIN
8.18.威尔逊定理/M题-崔东旭2.mp4
Normal file
BIN
8.18.威尔逊定理/M题-崔东旭2.mp4
Normal file
Binary file not shown.
BIN
8.18.威尔逊定理/O题-曾明宇.mp4
Normal file
BIN
8.18.威尔逊定理/O题-曾明宇.mp4
Normal file
Binary file not shown.
BIN
8.18.威尔逊定理/O题-邓伟康.mp4
Normal file
BIN
8.18.威尔逊定理/O题-邓伟康.mp4
Normal file
Binary file not shown.
BIN
8.19.缩点/A题-吴泳辉.mp4
Normal file
BIN
8.19.缩点/A题-吴泳辉.mp4
Normal file
Binary file not shown.
BIN
8.19.缩点/B题-林昊1.mp4
Normal file
BIN
8.19.缩点/B题-林昊1.mp4
Normal file
Binary file not shown.
BIN
8.19.缩点/B题-林昊2.mp4
Normal file
BIN
8.19.缩点/B题-林昊2.mp4
Normal file
Binary file not shown.
BIN
8.19.缩点/C题-曾明宇思路.mp4
Normal file
BIN
8.19.缩点/C题-曾明宇思路.mp4
Normal file
Binary file not shown.
BIN
8.19.缩点/C题.mp4
Normal file
BIN
8.19.缩点/C题.mp4
Normal file
Binary file not shown.
BIN
8.19.缩点/D题-陈志伟.mp4
Normal file
BIN
8.19.缩点/D题-陈志伟.mp4
Normal file
Binary file not shown.
BIN
8.19.缩点/SCC.pptx
(Stored with Git LFS)
Normal file
BIN
8.19.缩点/SCC.pptx
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -4,6 +4,10 @@
|
||||
#include <cmath>
|
||||
using namespace std;
|
||||
const int N=1e8+5;
|
||||
void initialise(int n)
|
||||
{
|
||||
|
||||
}
|
||||
int main()
|
||||
{
|
||||
int t;
|
||||
@ -13,6 +17,7 @@ int main()
|
||||
while(t--)
|
||||
{
|
||||
scanf("%d",&n);
|
||||
initialise(n);
|
||||
for(int i=1;i<=n; i++)
|
||||
{
|
||||
|
||||
|
113
新建文件夹/A - Bottom.cpp
Normal file
113
新建文件夹/A - Bottom.cpp
Normal file
@ -0,0 +1,113 @@
|
||||
#include<cstdio>
|
||||
#include<string.h>
|
||||
#include<algorithm>
|
||||
using namespace std;
|
||||
const int N=5e3+5,NN=N*N;
|
||||
int n,e;
|
||||
int to[NN],ne[NN];
|
||||
int h[N];
|
||||
int dfn[N],low[N];
|
||||
bool b[N];
|
||||
int s[N];//stack
|
||||
int cnt;
|
||||
int tot,top;
|
||||
int id;
|
||||
int nid[N];
|
||||
int now;
|
||||
bool no[N];
|
||||
int ans[N];
|
||||
int len;
|
||||
void add(int u,int v)
|
||||
{
|
||||
to[++cnt]=v;
|
||||
ne[cnt]=h[u];
|
||||
h[u]=cnt;
|
||||
}
|
||||
void initialise(int n)
|
||||
{
|
||||
cnt=0;
|
||||
tot=0;
|
||||
top=0;
|
||||
id=0;
|
||||
len=0;
|
||||
memset(b,0,sizeof(bool)*(n+1));
|
||||
memset(no,0,sizeof(bool)*(n+1));
|
||||
memset(h,0,sizeof(int)*(n+1));
|
||||
}
|
||||
void tarjan(int u)
|
||||
{
|
||||
// printf("%d ",u);
|
||||
int v;
|
||||
dfn[u]=++tot;
|
||||
low[u]=tot;
|
||||
s[++top]=u;
|
||||
b[u]=1;
|
||||
for(int i=h[u]; i; i=ne[i])
|
||||
{
|
||||
v=to[i];
|
||||
if(!dfn[v])
|
||||
{
|
||||
tarjan(v);
|
||||
low[u]=low[u]<low[v]? low[u]:low[v];
|
||||
}
|
||||
else
|
||||
{
|
||||
low[u]=low[u]<dfn[v]? low[u]:dfn[v];
|
||||
}
|
||||
}
|
||||
if(low[u]==dfn[u])
|
||||
{
|
||||
id++;
|
||||
now=s[top];
|
||||
while(dfn[now]!=low[now])
|
||||
{
|
||||
nid[now]=id;
|
||||
now=s[--top];
|
||||
b[now]=0;
|
||||
}
|
||||
b[u]=0;
|
||||
nid[u]=id;
|
||||
}
|
||||
}
|
||||
int main()
|
||||
{
|
||||
int u,v;
|
||||
while(~scanf("%d",&n)&&n)
|
||||
{
|
||||
initialise(n);
|
||||
scanf("%d",&e);
|
||||
for(int i=1; i<=e; i++)
|
||||
{
|
||||
scanf("%d%d",&u,&v);
|
||||
add(u,v);
|
||||
}
|
||||
//一开始放在前面,忽略了没有边的情况
|
||||
for(int i=1;i<=n;i++)
|
||||
{
|
||||
add(0,i);
|
||||
}
|
||||
tarjan(0);
|
||||
for(int i=1; i<=n; i++)
|
||||
{
|
||||
for(int j=h[i]; j; j=ne[j])
|
||||
{
|
||||
v=to[j];
|
||||
if(nid[v]!=nid[i])
|
||||
{
|
||||
no[nid[i]]=1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(int j=1; j<=n; j++)
|
||||
{
|
||||
if(!no[nid[j]])
|
||||
{
|
||||
printf("%d ",j);
|
||||
}
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
94
新建文件夹/D - Cross Swapping.cpp
Normal file
94
新建文件夹/D - Cross Swapping.cpp
Normal file
@ -0,0 +1,94 @@
|
||||
#include<cstdio>
|
||||
#include<string.h>
|
||||
#include<iostream>
|
||||
using namespace std;
|
||||
const int N=1e3+5;
|
||||
int a[N][N];
|
||||
bool b[N];
|
||||
int n;
|
||||
bool cmp(int k)
|
||||
{
|
||||
for(int i=1;i<k;i++)
|
||||
{
|
||||
if(a[k][i]>a[i][k])
|
||||
{
|
||||
// printf("%d(i xiao):%d %d\n",k,i,0^b[i]);
|
||||
return 0^b[i];
|
||||
}
|
||||
else if(a[k][i]<a[i][k])
|
||||
{
|
||||
// printf("%d(i big):%d %d\n",k,i,1^b[i]);
|
||||
return 1^b[i];
|
||||
}
|
||||
}
|
||||
for(int i=k+1;i<=n;i++)
|
||||
{
|
||||
if(a[k][i]<a[i][k])
|
||||
{
|
||||
// printf("%d(i xiao):%d %d\n",k,i,0^b[i]);
|
||||
return 0^b[i];
|
||||
}
|
||||
else if(a[k][i]>a[i][k])
|
||||
{
|
||||
// printf("%d(i big):%d %d\n",k,i,1^b[i]);
|
||||
return 1^b[i];
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int main()
|
||||
{
|
||||
int t;
|
||||
int k;
|
||||
scanf("%d",&t);
|
||||
while(t--)
|
||||
{
|
||||
scanf("%d",&n);
|
||||
memset(b,0,sizeof(bool)*(n+1));
|
||||
for(int i=1; i<=n; i++)
|
||||
{
|
||||
for(int j=1; j<=n; j++)
|
||||
{
|
||||
scanf("%d",&a[i][j]);
|
||||
// a[i][j]=(i-1)*n+j;
|
||||
// printf("%02d ",a[i][j]);
|
||||
}
|
||||
// printf("\n");
|
||||
}
|
||||
for(k=2; k<=n; k++)
|
||||
{
|
||||
if(a[k][1]<a[1][k])
|
||||
{
|
||||
b[k]=1;
|
||||
}
|
||||
}
|
||||
for(k=2; k<=n; k++)
|
||||
{
|
||||
if(!b[k])
|
||||
{
|
||||
if(cmp(k))
|
||||
b[k]=1;
|
||||
}
|
||||
}
|
||||
for(k=2; k<=n; k++)
|
||||
{
|
||||
if(b[k])
|
||||
{
|
||||
for(int i=1;i<=n;i++)
|
||||
{
|
||||
int tmp=a[k][i];
|
||||
a[k][i]=a[i][k];
|
||||
a[i][k]=tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
for(int i=1; i<=n; i++)
|
||||
{
|
||||
for(int j=1; j<=n; j++)
|
||||
{
|
||||
printf("%d ",a[i][j]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
}
|
BIN
新建文件夹/SCC.pptx
(Stored with Git LFS)
Normal file
BIN
新建文件夹/SCC.pptx
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user