I Love Matrix Forever
2016-11-12 16:13
253 查看
I Love Matrix Forever
题目大意:
就是给你一堆操作,求操作后矩阵内1的个数。30%:
直接暴力。100%:
理解:
设执行完第i个操作后的矩阵为F[i]。若不考虑操作4,则:
F[1]=>F[2]=>F[3]=>…
在理解了操作4的实际意义后,我们可以连父子边。
F[1]=>F[2]=>……
||
F[3]=>……
存父子边:
若有父子边:父 | 子 |
---|---|
5 | 6 |
3 | 4 |
1 | 3 |
1 | 2 |
3 | 5 |
父 | 子 |
---|---|
1 | 2 |
1 | 3 |
3 | 4 |
3 | 5 |
5 | 6 |
Start[i]与End[i]可以逐条访问父子边以求出。
回溯:
从根节点遍历,求出所有Ans。AC。
相关文章推荐
- Google-LOVE YOU FOREVER
- poj 2115 C Looooops His love for her is enshrined forever in his heart.扩展欧几里得
- End Less Love –Forever
- 欧美群星 -《Only Love Forever》(真情典藏)[MP3]
- 祝福朋友,Love Being Forever!
- foreverloveu
- oh forever love~
- maybe 《PRISON BREAK》lost my love forever。。
- 【LOVE】StarryNight Forever
- AS3 求Matrix变形后计算显示对象大小的矩形框算法
- POJ 3233 Matrix Power Series (矩阵分块,递推)
- set-matrix-zeroes
- Android_Matrix
- 【Codeforces Round 326 (Div 2)B】【质因数分解】Duff in Love n的最大因子使其不为平方数倍数
- bzoj2351 [BeiJing2011]Matrix
- Android画图之Matrix
- Search a 2D Matrix
- python的dataframe和matrix的互换方法
- for the love,for the dream
- leetcode 53:Spiral Matrix