模板(資料結構)

來源:互聯網
上載者:User

資料結構:

鏈式前向星(儲存結構)

矩陣快速冪

樹狀數組

RMQ問題

線段樹

manacher演算法




鏈式前向星(儲存結構)

http://blog.csdn.net/acdreamers/article/details/16902023  // 具體解析;

[cpp]  view plain  copy   // 按邊儲存   struct Edge   {        int next;        int to;        int w;   };      void add(int u,int v,int w)   {       edge[cnt].w = w;       edge[cnt].to = v;       edge[cnt].next = head[u];       head[u] = cnt++;   }  


矩陣快速冪:

[cpp]  view plain  copy   struct mat{       long long arr[2][2];       mat(){ memset(arr, 0, sizeof(arr)); }       mat mul(mat &b){           mat res;           for(int i = 0; i < 2; ++i){               for(int k = 0; k < 2; ++k){                   if(this->arr[i][k]){   //最佳化:0特別多時,複雜度可能會降低到O(n^2)                       for(int j = 0; j < 2; ++j){                           res.arr[i][j] += this->arr[i][k]*b.arr[k][j];                           if(res.arr[i][j] >= MOD) res.arr[i][j]%=MOD;                       }                   }               }           }           return res;       }   };  


樹狀數組:

[cpp] 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.