c题过了95%样例求助

我的思路是dfs遍历每一个点,找消灭敌人的最大值,但是只过了95%样例,有大佬是哪里错了吗
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int long long
const int mod=1e9+7;
int n,k,R;
struct ani
{
    int x,y,r;
}p[16];
vector<int> v[16][16];
bool stt[16];
bool dis(int i,int j,int x)
{
    if(((i-p[x].x)*(i-p[x].x)+(j-p[x].y)*(j-p[x].y))<=(R+p[x].r)*(R+p[x].r))
        return 1;
    else
        return 0;
}
int max1=0;
void dfs(int num,int xx,int yy,int sum)
{
    if(yy==15)
    {
        xx++;
        yy=0;
    }
    if(num==k||xx==15)
    {
        max1=max(max1,sum);
        return;
    }
    for(int i=xx;i<=14;i++)
    {
        for(int j=yy;j<=14;j++)
        {
            bool st[16];
            memcpy(st,stt,sizeof(st));
            int s=0;
            for(auto w:v[i][j])
                if(stt[w]) s++;
            int ss=v[i][j].size()-s;
            for(auto w:v[i][j])
                stt[w]=1;
            dfs(num+1,i,j+1,sum+ss);
            memcpy(stt,st,sizeof(stt));
        }
    }
}
signed main()
{
    cin>>n>>k>>R;
    for(int i=1;i<=n;i++)
    {
        cin>>p[i].x>>p[i].y>>p[i].r;
        p[i].x+=7;
        p[i].y+=7;
    }
    for(int i=0;i<=14;i++)
    {
        for(int j=0;j<=14;j++)
        {
            for(int q=1;q<=n;q++)
            if(dis(i,j,q))
            {
                v[i][j].push_back(q);
            }
        }
    }
    dfs(0,0,0,0);
    cout<<max1;
    return 0;
}


全部评论
hack: 5 2 1 -4 -5 1 -3 -4 3 -4 -5 1 -7 3 1 -7 -1 2 这组数据你的程序就错了
点赞 回复
分享
发布于 2021-02-05 20:44
hack: 8 3 1 -2 5 4 -5 1 1 2 4 2 -5 7 5 3 4 5 -7 4 1 -1 1 1 7 7 4 标程8,你的7
点赞 回复
分享
发布于 2021-02-05 20:50
滴滴
校招火热招聘中
官网直投

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务