/ Randle /

记录详情

Wrong Answer

/in/foo.cc: In function 'int main()':
/in/foo.cc:37:24: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
     for(int k=1;k<(1<<n+1);k++)
                       ~^~
/in/foo.cc:59:30: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
      printf("%d\n",f[0][(1<<n+1)-1]);
                             ~^~
# 状态 耗时 内存占用
#1 Wrong Answer 14ms 10.25 MiB
#2 Wrong Answer 10ms 10.215 MiB
#3 Wrong Answer 9ms 10.375 MiB
#4 Wrong Answer 12ms 10.25 MiB
#5 Wrong Answer 14ms 10.375 MiB
#6 Wrong Answer 13ms 10.25 MiB
#7 Wrong Answer 11ms 10.367 MiB
#8 Wrong Answer 22ms 10.363 MiB
#9 Wrong Answer 15ms 10.34 MiB
#10 Wrong Answer 14ms 10.34 MiB

代码

#include<iostream>

#include<cstdio>

#include<cstring>

using namespace std;

int n;

int a[20][20];

int f[20][(1<<17)+56];

int main()

{

scanf("%d",&n);

for(int i=0;i<=n;i++) 

for(int j=0;j<=n;j++)  scanf("%d",&a[i][j]);

for(int k=0;k<=n;k++)

   for(int i=0;i<=n;i++)

       for(int j=0;j<=n;j++)  

           if(i!=k && j!=k && i!=j)  a[i][j]=min(a[i][j],a[i][k]+a[k][j]);

memset(f,127/3,sizeof(f));

  

    for(int k=1;k<(1<<n+1);k++)

    {

    for(int i=0;i<=n;i++)

    {

   if((1<<i) &k) 

    for(int j=0;j<=n;j++)

    {

    f[i][k]=min(f[i][k],f[j][k-(1<<i)]+a[j][i]);

    }

    }

    }

     printf("%d\n",f[0][(1<<n+1)-1]);

     return 0;

 }

信息

递交者
类型
递交
题目
送外卖
题目数据
下载
语言
C++
递交时间
2017-11-06 21:28:45
评测时间
2017-11-06 21:28:46
评测机
分数
0
总耗时
137ms
峰值内存
10.375 MiB