当前位置:网站首页>[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:bitset
01Fig.
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 dansbiset
Moyenne,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 ;
}
边栏推荐
- Vertx's responsive MySQL template
- 【LeetCode】4. Best Time to Buy and Sell Stock·股票买卖最佳时机
- Pat class a 1031 Hello world for u
- PHP常用排序算法
- opensips与对方tls sip trunk对接注意事项
- Grpc message sending of vertx
- [coppeliasim4.3] C calls UR5 in the remoteapi control scenario
- 项目经验分享:基于昇思MindSpore,使用DFCNN和CTC损失函数的声学模型实现
- Lucene merge document order
- Pat class a 1030 travel plan
猜你喜欢
技术干货|AI框架动静态图统一的思考
Technical dry goods | reproduce iccv2021 best paper swing transformer with Shengsi mindspire
Analysis of the ninth Blue Bridge Cup single chip microcomputer provincial competition
項目經驗分享:實現一個昇思MindSpore 圖層 IR 融合優化 pass
图像识别与检测--笔记
Pat grade a 1029 median
Redis批量启停脚本
[Development Notes] cloud app control on device based on smart cloud 4G adapter gc211
Lucene skip table
[coppeliasim4.3] C calls UR5 in the remoteapi control scenario
随机推荐
Reconnaissance et détection d'images - Notes
技术干货|关于AI Architecture未来的一些思考
【MySQL 12】MySQL 8.0.18 重新初始化
Grpc message sending of vertx
Collector in ES (percentile / base)
华为S5700交换机初始化和配置SSH和TELNET远程登录方法
HDMI2.1与HDMI2.0的区别以及转换PD信号。
OSPF protocol summary
PHP常用排序算法
PAT甲级 1027 Colors in Mars
[MySQL 13] if you change your password for the first time after installing mysql, you can skip MySQL password verification to log in
技术干货|利用昇思MindSpore复现ICCV2021 Best Paper Swin Transformer
IndexSort
Harmonyos third training notes
Analysis of the eighth Blue Bridge Cup single chip microcomputer provincial competition
Application of pigeon nest principle in Lucene minshouldmatchsumscorer
什么是定义?什么是声明?它们有何区别?
Pat class a 1030 travel plan
Mail sending of vertx
Pat grade a 1027 colors in Mars