当前位置:网站首页>[at] abc 258G - Triangle 三元組可達-暴力
[at] abc 258G - Triangle 三元組可達-暴力
2022-07-03 07:44:00 【*DDL_GzmBlog】
前言
t a g : tag : tag:bitset01圖
傳送門:
題意 :
給定一個 01 01 01完全圖, 1 1 1錶示這兩個點有邊相連, 0 0 0錶示這兩個點沒有邊相連
詢問有多少組三元組 ( i , j , k ) (i,j,k) (i,j,k),滿足兩兩之間有邊相連
思路 :
暴力的做法 n 3 n^3 n3,因為圖只存在 01 01 01,我們考慮使用比特運算减去一層的枚舉
即bitset , 我們將狀態存入biset中,然後枚舉兩行之間的狀態,進行 & \& &運算
顯然的如果 & = 1 \&=1 &=1那麼,存在三個點是可達的,時間複雜度 n 2 l o g n n^2logn n2logn
code :
void solve(){
int n;cin>>n;
vector<bitset<N>> v(n);
vector<string> s(n);
for(int i = 0; i < n; i ++ ){
cin>>s[i];
for(int j = 0 ; j < n ; j ++ ){
if(s[i][j] == '1') v[i][j] = 1;
}
}
ll ans = 0 ;
for(int i = 0 ; i< n ; i ++ ){
for(int j = 0 ; j< i ; j ++ ){
if(s[i][j] == '1') ans += (v[i]&v[j]).count();
}
}
cout<<ans/3<<endl;
}
int main(){
//int t;cin>>t;while(t--)
solve();
return 0 ;
}
边栏推荐
- Es writing fragment process
- The babbage industrial policy forum
- Industrial resilience
- Responsive MySQL of vertx
- Technical dry goods | hundred lines of code to write Bert, Shengsi mindspire ability reward
- Go language foundation ----- 10 ----- string related operations (operation function, string conversion)
- Precautions for opensips and TLS SIP trunk docking
- Technical dry goods | alphafold/ rosettafold open source reproduction (2) - alphafold process analysis and training Construction
- 技术干货|昇思MindSpore算子并行+异构并行,使能32卡训练2420亿参数模型
- Analysis of the ninth Blue Bridge Cup single chip microcomputer provincial competition
猜你喜欢

The concept of C language pointer

Lucene introduces NFA

Go language foundation ----- 01 ----- go language features

Go language foundation ----- 08 ----- interface

Go language foundation ------ 12 ------ JSON

Pat grade a 1027 colors in Mars

Go language foundation ----- 05 ----- structure

Es writing fragment process

Pat class a 1032 sharing

Analysis of the ninth Blue Bridge Cup single chip microcomputer provincial competition
随机推荐
Go language foundation ----- 08 ----- interface
[at] abc 258G - Triangle 三元组可达-暴力
The babbage industrial policy forum
Segment read
Analysis of the problems of the 12th Blue Bridge Cup single chip microcomputer provincial competition
Vertx metric Prometheus monitoring indicators
华为交换机:配置telnet和ssh、web访问
Redis查看客户端连接
Hnsw introduction and some reference articles in lucene9
C2-关于VCF文件合并的几种方法
Go language foundation ----- 06 ----- anonymous fields, fields with the same name
Partage de l'expérience du projet: mise en œuvre d'un pass optimisé pour la fusion IR de la couche mindstore
Go language foundation ----- 15 ----- reflection
Lucene hnsw merge optimization
OSPF protocol summary
[MySQL 11] how to solve the case sensitive problem of MySQL 8.0.18
Go language foundation ----- 02 ----- basic data types and operators
微软安全响应中心
Professor Zhang Yang of the University of Michigan is employed as a visiting professor of Shanghai Jiaotong University, China (picture)
Technical dry goods | reproduce iccv2021 best paper swing transformer with Shengsi mindspire