UVA11464 - Even Parity

链接

https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2459

题解

枚举第一行,递推出剩下的行,然后验证,时间复杂度 Θ(2nn2) Θ ( 2 n n 2 )
这题写出来 10min 10 m i n debug d e b u g 半小时,原来是因为我边界没有处理好,多组数据没有清空数组QwQ

代码

//枚举 
#include <cstdio>
#include <algorithm>
#define maxn 20
#define inf 0x3f3f3f3f
using namespace std;
int T, n, ans, a[maxn][maxn], b[maxn][maxn], cost;
void update(int t)
{
    int i, j;
    for(i=1;i<=n;i++)b[1][i]=t&1, t>>=1;
    for(i=0;i<=n+1;i++)b[0][i]=b[n+1][i]=b[i][0]=b[i][n+1]=0;
    for(i=2;i<=n;i++)for(j=1;j<=n;j++)b[i][j]=b[i-1][j-1]^b[i-1][j+1]^b[i-2][j];
    for(i=1;i<=n;i++)for(j=1;j<=n;j++)
        if(b[i+1][j]^b[i][j-1]^b[i][j+1]^b[i-1][j])return;
    cost=0;
    for(i=1;i<=n;i++)for(j=1;j<=n;j++)
    {
        if(a[i][j]==1 and b[i][j]==0)return;
        if(a[i][j]==0 and b[i][j]==1)cost++;
    }
    ans=min(ans,cost);
}
int main()
{
    int i, j, c, t;
    scanf("%d",&T);
    for(c=1;c<=T;c++)
    {
        scanf("%d",&n);
        for(i=1;i<=n;i++)for(j=1;j<=n;j++)scanf("%d",a[i]+j);
        ans=inf;
        for(t=0;t<1<<n;t++)update(t);
        printf("Case %d: ",c); 
        if(ans==inf)printf("-1\n");
        else printf("%d\n",ans);
    }
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
can achieve near-Shannon limit performance. Can you explain how protograph-based LDPC codes work and what makes them effective in achieving high accuracy? Sure, I'd be happy to explain. LDPC codes are a type of error-correcting code used in digital communication systems to mitigate the effects of noise and interference. Protograph-based LDPC codes are a type of LDPC code that use a protograph matrix to describe the code structure. The protograph matrix specifies the connectivity pattern of the code's check matrix, which is used to detect and correct errors in the transmitted data. The use of protographs allows for the creation of highly structured LDPC codes with a well-defined pattern of connections between nodes. This structure makes it easier to design and analyze the codes, which leads to better performance. Additionally, protograph-based LDPC codes can be optimized for specific transmission scenarios, further improving their performance. The near-Shannon limit performance of protograph-based LDPC codes can be attributed to their ability to correct a high percentage of errors with a low probability of error. This is achieved through the iterative decoding process, where the received data is repeatedly processed through the protograph-based LDPC code until the probability of error is minimized. By carefully constructing the protograph matrix and optimizing the decoding algorithm, protograph-based LDPC codes can achieve extremely high accuracy in noisy communication channels.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值