当前位置:网站首页>[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 ;
}
边栏推荐
- 微软安全响应中心
- Es writing fragment process
- 【MySQL 14】使用DBeaver工具远程备份及恢复MySQL数据库(Linux 环境)
- Harmonyos third training notes
- Unity XR实现交互(抓取,移动旋转,传送,射击)-Pico
- Responsive MySQL of vertx
- PAT甲级 1028 List Sorting
- Go language foundation ----- 03 ----- process control, function, value transfer, reference transfer, defer function
- 在浏览器输入url后执行什么
- OSPF protocol summary
猜你喜欢

Technical dry goods Shengsi mindspire elementary course online: from basic concepts to practical operation, 1 hour to start!

【LeetCode】4. Best time to buy and sell stock

Project experience sharing: realize an IR Fusion optimization pass of Shengsi mindspire layer

Pat class a 1030 travel plan

Technical dry goods | hundred lines of code to write Bert, Shengsi mindspire ability reward

图像识别与检测--笔记

Technical dry goods | alphafold/ rosettafold open source reproduction (2) - alphafold process analysis and training Construction

项目经验分享:实现一个昇思MindSpore 图层 IR 融合优化 pass

Go language foundation ----- 10 ----- string related operations (operation function, string conversion)

Go language foundation ----- 13 ----- file
随机推荐
【LeetCode】3. Merge two sorted lists · merge two ordered linked lists
基于RNA的新型癌症疗法介绍
yarn link 是如何帮助开发者对 NPM 包进行 debug 的?
IndexSort
List exercises after class
s7700设备如何清除console密码
Unity XR实现交互(抓取,移动旋转,传送,射击)-Pico
【MySQL 12】MySQL 8.0.18 重新初始化
Go language foundation ------ 12 ------ JSON
Lucene skip table
Go language foundation ------ 14 ------ gotest
PHP常用排序算法
experiment.........
Robots protocol
技术干货|利用昇思MindSpore复现ICCV2021 Best Paper Swin Transformer
pgAdmin 4 v6.11 发布,PostgreSQL 开源图形化管理工具
Redis批量启停脚本
【LeetCode】3. Merge Two Sorted Lists·合并两个有序链表
技术干货|昇思MindSpore Lite1.5 特性发布,带来全新端侧AI体验
Epoll related references