zoukankan      html  css  js  c++  java
  • 2007-2008 Winter Petrozavodsk Camp, Andrew Stankevich Contest 28 (ASC 28)J. Triatrip(bitset优化)

    https://codeforc.es/gym/100342

    bitset存边搞一搞

     1 #include<bits/stdc++.h>
     2 using namespace std;
     3 typedef long long ll;
     4 const int N=2e3+5;
     5 bitset<N>in[N],out[N],t;
     6 char s[N][N];
     7 int n;
     8 int main(){
     9     freopen("triatrip.in","r",stdin);//没这两行就wa 服了
    10     freopen("triatrip.out","w",stdout);
    11     scanf("%d",&n);
    12     for(int i=1;i<=n;i++){
    13         scanf("%s",s[i]+1);
    14     }
    15     for(int i=1;i<=n;i++){
    16         for(int j=1;j<=n;j++){
    17             if(s[i][j]=='+'){
    18                 in[i][j]=1;
    19                 out[j][i]=1;
    20             }
    21         }
    22     }
    23     ll ans=0;
    24     for(int i=1;i<=n;i++){
    25         for(int j=1;j<=n;j++){
    26             if(s[i][j]=='+'){
    27                 t=(in[j])&(out[i]);
    28                 ans+=t.count();
    29             }
    30         }
    31     }
    32     cout<<ans/3<<endl;
    33 }
  • 相关阅读:
    leetcode165
    leetcode63
    leetcode92
    leetcode86
    捣鼓Haskell
    递归操作链表
    treap(堆树)
    贪心策略 — 分数背包
    LeetCode.21
    LeetCode.94
  • 原文地址:https://www.cnblogs.com/ccsu-kid/p/11470268.html
Copyright © 2011-2022 走看看