当前位置:网站首页>[at] ABC 258g - triple Reach - violence
[at] ABC 258g - triple Reach - violence
2022-07-03 07:44:00 【* DDL Gzmblog】
Préface
t a g : tag : tag:bitset01Fig.
Porte de transfert:
Titre :
Compte tenu d'un 01 01 01Graphique complet, 1 1 1Cela signifie que les deux points ont des bords reliés, 0 0 0Ça veut dire qu'il n'y a pas de bords reliant ces deux points
Demandez combien de triples il y a ( i , j , k ) (i,j,k) (i,j,k),Il y a des bords qui relient les deux
Idées :
Pratiques violentes n 3 n^3 n3,Parce que le graphique n'existe que 01 01 01,Nous envisageons d'utiliser des opérations de bits moins une couche d'énumération
C'est - à - dire:bitset , Nous mettons l'état dansbisetMoyenne,Puis énumérez les états entre les deux lignes,En cours & \& &Opération
Apparemment, si & = 1 \&=1 &=1Alors,Trois points sont accessibles,Complexité temporelle 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 ;
}
边栏推荐
- Pat class a 1032 sharing
- OSPF protocol summary
- EtherCAT state machine transition (ESM)
- What did the DFS phase do
- 技术干货|AI框架动静态图统一的思考
- Technical dry goods | reproduce iccv2021 best paper swing transformer with Shengsi mindspire
- An overview of IfM Engage
- [at] abc 258G - Triangle 三元组可达-暴力
- HCIA notes
- Vertx's responsive MySQL template
猜你喜欢

【CoppeliaSim4.3】C#调用 remoteApi控制场景中UR5

【MySQL 12】MySQL 8.0.18 重新初始化

Leetcode 213: looting II

一篇文章让你读懂-曼彻斯特编码

Research shows that breast cancer cells are more likely to enter the blood when patients sleep

Hnsw introduction and some reference articles in lucene9

Analysis of the eighth Blue Bridge Cup single chip microcomputer provincial competition

Go language foundation ----- 13 ----- file

Go language foundation ----- 11 ----- regular expression

技术干货|百行代码写BERT,昇思MindSpore能力大赏
随机推荐
【踩坑系列】mysql 修改root密码失败
IndexSort
Redis查看客户端连接
截图工具Snipaste
项目经验分享:基于昇思MindSpore,使用DFCNN和CTC损失函数的声学模型实现
Harmonyos third training notes
Image recognition and detection -- Notes
Shengsi mindspire is upgraded again, the ultimate innovation of deep scientific computing
【MySQL 13】安装MySQL后第一次修改密码,可以可跳过MySQL密码验证进行登录
HarmonyOS第三次培训笔记
圖像識別與檢測--筆記
Partage de l'expérience du projet: mise en œuvre d'un pass optimisé pour la fusion IR de la couche mindstore
Go language - loop statement
Logging log configuration of vertx
Analysis of the problems of the 7th Blue Bridge Cup single chip microcomputer provincial competition
[at] abc 258G - Triangle 三元组可达-暴力
Go language foundation ----- 04 ----- closure, array slice, map, package
C2-关于VCF文件合并的几种方法
Professor Zhang Yang of the University of Michigan is employed as a visiting professor of Shanghai Jiaotong University, China (picture)
Vertx's responsive redis client