sgu-262 Symbol Recognition
来源:互联网 发布:云计算安全关键技术 编辑:程序博客网 时间:2024/05/16 06:17
题目大意:
有
解题思路:
我们观察到
所以最后的答案就是
AC代码:
#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <algorithm>#include <iostream>using namespace std;int N,M;int K;int ch[10][20][20]={{{0}}};int change[20][20]={{0}};int F[33000]={0};bool Matrix[33000][11][11]={{{0}}};int need[20][20]={{0}};int main(){ scanf("%d%d%d",&N,&M,&K); for(int i=1;i<=K;i++) for(int p=1;p<=N;p++) for(int q=1;q<=M;q++) { scanf("%1d",&ch[i][p][q]); for(int j=1;j<i;j++) if(ch[i][p][q]!=ch[j][p][q]) change[p][q]|=(1<<((i-2)*(i-1)/2-1+j)); } memset(F,0x3f3f3f3f,sizeof(F)); int Max=(1<<(K*(K-1)/2))-1; F[0]=0; int cnt=0; for(int i=1;i<=N;i++) for(int j=1;j<=M;j++) { for(int p=Max-1;p>=0;p--) { if(change[i][j]==0) continue; if(F[p]+1<F[p|change[i][j]]) { F[p|change[i][j]]=F[p]+1; memcpy(Matrix[p|change[i][j]],Matrix[p],sizeof(Matrix[p])); Matrix[p|change[i][j]][i][j]=1; } } } printf("%d\n",F[Max]); for(int i=1;i<=N;i++) { for(int j=1;j<=M;j++) printf("%d",Matrix[Max][i][j]); puts(""); } return 0;}
0 0
- sgu-262 Symbol Recognition
- sgu262:Symbol Recognition(状压DP)
- SGU
- SGU
- SGU
- SGU
- SGU
- SGU
- (SGU
- SGU
- SGU
- SGU
- SGU
- SGU
- SGU
- SGU
- symbol
- symbol
- facebook静态代码检查工具开源了!
- 数字在排序数组中出现的次数
- 编码格式
- 协同程序Coroutine
- WPF中的ListBox-——滚动条重绘经验分享
- sgu-262 Symbol Recognition
- 二分查找(递归与非递归两种方法实现)
- Python字符串的encode与decode
- HTML转PDF(java版,经过测试好用,可以先用简单的html调试)
- 修改表内容如果为 NULL,则改为空字符串
- 新浪sae 数据库连接(java版)
- leetcode--ConstructBinaryTreefromInorderandPostorderTraversal
- Remove Nth Node From End of List
- Linux文件系统管理(3)