[Data Structure] [Status Compression] Brush

Nothing else, I just want to remember those functions by myself

1>floyd+bitset optimization

#include 

#include
#include
using namespace std;
int n;
const int N=2003;
char s[N];
bitset
bs[N]; int main( )
{
scanf(
"%d",&n);
for(int i=1;i<=n;i++)
{
scanf(
"%s",s+1);
for(int j=1;j<=n;j++)
if(s[j]=='< span style="color: #800000;">1
') bs[ i][j]=1;
bs[i][i]
=1;
}

int ans=0;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
if(bs[i][j])
bs[i]
|= bs[j];

ans
+=bs[i].count();
}

printf(
"%d ",ans);
return 0;
}

#include

#include
#include
using namespace std;
int n;
const int N=2003;
char s[N];
bitset
bs[N]; int main( )
{
scanf(
"%d",&n);
for(int i=1;i<=n;i++)
{
scanf(
"%s",s+1);
for(int j=1;j<=n;j++)
if(s[j]=='< span style="color: #800000;">1
') bs[ i][j]=1;
bs[i][i]
=1;
}

int ans=0;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
if(bs[i][j])
bs[i]
|= bs[j];

ans
+=bs[i].count();
}

printf(
"%d ",ans);
return 0;
}

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 5017 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.