Counting 4-Cliques

链接:https://www.nowcoder.com/acm/contest/145/E

题目描述

You love doing graph theory problems. You've recently stumbled upon a classical problem : Count the number of 4-cliques in an undirected graph.

Given an undirected simple graph G, a 4-clique of G is a set of 4 nodes such that all pairs of nodes in this set are directly connected by an edge.

This task would be too easy for you, wouldn't it? Thus, your task here is to find an undirected simple graph G with exactly k 4-cliques. Can you solve this task?

 

输入描述:

The first line of input contains a single integer k (1 ≤ k ≤ 106).

输出描述:

On the first line, output two space-separated integers, n, m (1 ≤ n ≤ 75, 1 ≤ m ≤ n * (n - 1) / 2). On the next m lines, output two space-separated integers denoting an edge of the graph u, v (1 ≤ u, v ≤ n), where u and v are the endpoints of the edge.

Your graph must not contain any self-loops or multiple edges between the same pair of nodes. Any graph that has exactly k 4-cliques and satisfies the constraints will be accepted. It can be proven that a solution always exist under the given constraints.

示例1

输入

复制

1

输出

复制

4 6
1 2
1 3
1 4
2 3
2 4
4 3

说明

In the sample, the whole graph is a 4-clique.

题意:

就是完全图的问题,构造一个<=75个点的图,使得⼤小为4的团(就是指互相可达的四个点)恰有k个。 k<=1e6

分析:

有点小技巧,就是拼数的时候,有一个特殊的边界,K最大的完全图是71,但是上下的团不能用剩余的4个点表示,但是可以用70个点的完全图和5个点分别于这70个点相连可以构成。五个点之间没有边,他们只会向t个点构成的完全图连边。如果连了了x个,构成C(x, 3)个⼤大⼩小为4个团。
代码:

#include<bits/stdc++.h>
using namespace std;
vector<int>v[100];
int c[80][5],dp[10][211005];
int num,str,maxn;
void pp()
{
    memset(c, 0, sizeof(c));
    c[1][1] = 1;
    for (int i = 0; i < 80; i++)
        c[i][0] = 1;
    for (int i = 1; i < 80; i++)
        for (int j = 1; j < 5; j++)
            c[i][j] = c[i - 1][j-1] + c[i - 1][j];
}
void dfs(int len,int key)
{
    int i;
    if(len==0)return;
    for(i=0;i<=num;i++)
    {
        if(dp[len-1][key-c[i][3]])
        {
            v[str].push_back(i);
            maxn+=i;
            str++;
            dfs(len-1,key-c[i][3]);
            return;
        }
    }

}
int main()
{
    int i,j,k,n,sum,sec,m,l;
    pp();
    memset(dp,0,sizeof(dp));
    scanf("%d",&k);
    num=-1;
    for(i=4;i<71;i++)
    {
        if(c[i][4]<=k)num=i;
    }
    for(i=1;i<80;i++)
        v[i].clear();
    sum=k-c[num][4];
    dp[0][0]=1;
    str=num+1;
    //printf("num =%d\n",num);
    maxn=num*(num-1)/2;
    for(i=0;i<5;i++)
    {
        for(j=0;j<100002;j++)
        {
            if(dp[i][j])
            {
                for(l=0;l<=num;l++)
                {
                    if(c[l][3]+j<=1000000)
                    dp[i+1][c[l][3]+j]=1;
                }
            }
        }
    }
    dfs(5,sum);
    printf("%d %d\n",str-1,maxn);
    for(i=1;i<num;i++)
    {
        for(j=i+1;j<=num;j++)
            printf("%d %d\n",i,j);
    }
    for(i=num+1;i<str;i++)
    {
        for(j=1;j<=v[i][0];j++)
            printf("%d %d\n",i,j);
    }

}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
boosting-crowd-counting-via-multifaceted-attention是一种通过多方面注意力提升人群计数的方法。该方法利用了多个方面的特征来准确估计人群数量。 在传统的人群计数方法中,往往只关注人群的整体特征,而忽略了不同区域的细节。然而,不同区域之间的人群密度可能存在差异,因此细致地分析这些区域是非常重要的。 该方法首先利用卷积神经网络(CNN)提取图像的特征。然后,通过引入多个注意力机制,分别关注图像的局部细节、稀疏区域和密集区域。 首先,该方法引入了局部注意力机制,通过对图像的局部区域进行加权来捕捉人群的局部特征。这使得网络能够更好地适应不同区域的密度变化。 其次,该方法采用了稀疏区域注意力机制,它能够识别图像中的稀疏区域并将更多的注意力放在这些区域上。这是因为稀疏区域往往是需要重点关注的区域,因为它们可能包含有人群密度的极端变化。 最后,该方法还引入了密集区域注意力机制,通过提取图像中人群密集的区域,并将更多的注意力放在这些区域上来准确估计人群数量。 综上所述,boosting-crowd-counting-via-multifaceted-attention是一种通过引入多个注意力机制来提高人群计数的方法。它能够从不同方面细致地分析图像,并利用局部、稀疏和密集区域的特征来准确估计人群数量。这个方法通过考虑人群分布的细节,提供了更精确的人群计数结果。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值