当前位置:网站首页>[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 ;
}
边栏推荐
- 华为S5700交换机初始化和配置telnet,ssh用户方法
- Harmonyos third training notes
- Go language foundation ----- 06 ----- anonymous fields, fields with the same name
- 【踩坑系列】mysql 修改root密码失败
- Analysis of the problems of the 7th Blue Bridge Cup single chip microcomputer provincial competition
- 技术干货|AI框架动静态图统一的思考
- Vertx metric Prometheus monitoring indicators
- Project experience sharing: Based on mindspore, the acoustic model is realized by using dfcnn and CTC loss function
- 【LeetCode】3. Merge two sorted lists · merge two ordered linked lists
- Go language foundation ------17 ----- channel creation, read-write, security shutdown, multiplexing select
猜你喜欢

Inverted chain disk storage in Lucene (pfordelta)

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

PAT甲级 1027 Colors in Mars

Professor Zhang Yang of the University of Michigan is employed as a visiting professor of Shanghai Jiaotong University, China (picture)

Pat grade a 1027 colors in Mars
![[mindspire paper presentation] summary of training skills in AAAI long tail problem](/img/34/9c9ec1b94edeecd4a3e7f20fdd8356.png)
[mindspire paper presentation] summary of training skills in AAAI long tail problem

Unity XR实现交互(抓取,移动旋转,传送,射击)-Pico

【MindSpore论文精讲】AAAI长尾问题中训练技巧的总结
![[MySQL 12] MySQL 8.0.18 reinitialization](/img/e1/9874df18bbc8d80c3c5c5fe39aefc9.png)
[MySQL 12] MySQL 8.0.18 reinitialization

Harmonyos third training notes
随机推荐
Redis查看客户端连接
华为交换机配置ssh登录远程管理交换机
Vertx multi vertical shared data
技术干货|昇思MindSpore NLP模型迁移之Roberta ——情感分析任务
PHP常用排序算法
Go language foundation ----- 07 ----- method
Structure of golang
【LeetCode】3. Merge Two Sorted Lists·合并两个有序链表
PDO and SDO concepts
Lucene skip table
Pat class a 1031 Hello world for u
The concept of C language pointer
Reconnaissance et détection d'images - Notes
Go language foundation ----- 03 ----- process control, function, value transfer, reference transfer, defer function
Industrial resilience
Go language foundation ----- 18 ----- collaboration security, mutex lock, read-write lock, anonymous lock, sync Once
Project experience sharing: realize an IR Fusion optimization pass of Shengsi mindspire layer
Vertx's responsive MySQL template
Unity XR实现交互(抓取,移动旋转,传送,射击)-Pico
Technical dry goods | alphafold/ rosettafold open source reproduction (2) - alphafold process analysis and training Construction