Jewel Magic
题目描述
[problemUrl]: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=229&page=show_problem&problem=3147
[PDF](https://uva.onlinejudge.org/external/119/p11996.pdf)
![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA11996/2bab589816720983ab635f9484728b78d4993b0f.png)
输入输出格式
输入格式
![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA11996/f01f1337a503a06d908bccf8ce9f1b2f678759c7.png)
输出格式
![](https://cdn.luogu.com.cn/upload/vjudge_pic/UVA11996/07591e46a067540334a0ba60ca15ea251c41da0e.png)
输入输出样例
输入样例 #1
12 9
000100001100
1 0 1
4 2 6
3 7 10
4 1 7
2 9
4 3 11
4 1 9
4 1 7
4 2 3
输出样例 #1
3
6
2
0
3
2