XidianOJ 1177 Counting Stars】的更多相关文章

题目描述 "But baby, I've been, I've been praying hard,     Said, no more counting dollars     We'll be counting stars" Grandpa Shaw loves counting stars. One evening he was sitting in his armchar, trying to figure out this problem. Consider the sky…
Counting Stars 题目链接:http://acm.xidian.edu.cn/problem.php?id=1177 离线+一维树状数组 一眼扫过去:平面区间求和,1e6的数据范围,这要hash+二维树状数组吧?这么短时间我肯定调不出来,果断弃... 结束后有人说一维树状数组可以做,ヾ(。`Д´。)离线啊没想到. 然后就成了水题...(坐标要++,因为是从零开始的) 感悟:离线算法在某种情况下可以降低复杂度的维度. 代码如下: #include<cstdio> #include&l…
Problem Description Little A is an astronomy lover, and he has found that the sky was so beautiful!So he is counting stars now!There are n stars in the sky, and little A has connected them by m non-directional edges.It is guranteed that no edges conn…
Problem Description Little A is an astronomy lover, and he has found that the sky was so beautiful! So he is counting stars now! There are n stars in the sky, and little A has connected them by m non-directional edges. It is guranteed that no edges c…
hdu 6184 Counting Stars(三元环计数) 题意: 给一张n个点m条边的无向图,问有多少个\(A-structure\) 其中\(A-structure\)满足\(V=(A,B,C,D)\) && \(E=(AB,BC,CD,DA,AC)\) 显然\(A-structure\)是由两个有公共边的三元环构成的 \(1 <=n <= 1e5\) \(1 <= m <= min(2e5,n*(n-1)/2)\) 思路: 三元环计数 做法1. ①统计每个点…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6184 题意: n个点m条边的无向图,问有多少个A-structure 其中A-structure满足V=(A,B,C,D) && E=(AB,BC,CD,DA,AC) 解法: 可以看出A-structure是由两个有公共边的三元环构成的,然后就变成了这道题. http://www.cnblogs.com/spfa/p/7495438.html #include <stdio.h>…
题面 传送门 给出一张无向图,求 \(4\) 个点构成两个有公共边的三元环的方案数. 题解 orz余奶奶,orz zzk 首先,如果我们知道经过每条边的三元环个数\(cnt_i\),那么答案就是\(\sum_{i=1}^m{cnt_i\choose 2}\) 所以现在问题就是该怎么数三元环 据说有一个设阈值的\(O(m\sqrt{m})\)的做法,不过常数太大了,这里不讲 我们把每一条边重定向,设它连接的两个点的度数分别为\(deg_u\)和\(deg_v\),那么把这条边定为从度数大的连向度数…
题目链接 hdu6184 题解 题意是让我们找出所有的这样的图形: 我们只需要求出每条边分别在多少个三元环中,记为\(x\),再然后以该点为中心的图形数就是\({x \choose 2}\) 所以我们只需找出所有三元环 据说这是一个套路题 我们将所有无向边改为有向边,由度数小的向度数大的连边,度数相同就由编号小的向编号大的 容易发现这样建图一定是一个\(DAG\) 然后我们枚举边,将边的两端点出边的到达的点打上标记,当一个点被打上同一个标记时,就成环了 因为是\(DAG\)容易发现这样找环不会重…
1.Sign 题目:Good Luck!flag{X-nuca@GoodLuck!} Flag直接写在题目上了,flag{X-nuca@GoodLuck!} 2.BaseCoding 提示:这是编码不是加密哦!一般什么编码里常见等号? 题目:这一串字符好奇怪的样子,里面会不会隐藏什么信息?http://question1.erangelab.com/ Base64-- 访问后得到一串含有等号的字符,然后base64解码得到flag 3.BaseInjection 提示:试试万能密码 题目:不知道…
CODE: #!/usr/bin/python # -*- coding: utf-8 -*- ''' Created on 2014-7-4 @author: guaguastd @name: findPopularRepost.py ''' if __name__ == '__main__': #import json # get weibo_api to access sina api from sinaWeiboLogin import sinaWeiboLogin sinaWeiboA…
Description \(n\) 个点 \(m\) 条边,每个点有一个点权 \(a_i\). 对于任意一个三元环 \((i,j,k)(i<j<k)\),它的贡献为 \(\max(a_i,a_j,a_k)\),求所有三元环的贡献和. Input The first line of the standard input contains two integers n and m (1<=N<=100000,1<=M<=250000) separated by a sing…
A: A Math Problem 题意:给出一个n,找出有多少个k满足kk  <= n 思路: kk的增长很快,当k == 16 的时候就已经超过1e18 了,对于每一次询问,暴力一下就可以 #include <bits/stdc++.h> using namespace std; typedef long long ll; ll n; inline ll qpow(ll x, ll n) { ll ans = ; ll base = x; while (n) { ) ans = an…
GitHub已然是全球最流行的开源项目托管平台,项目数量眼下已经达到了千万级别.Adereth在Counting Stars on GitHub一文提供了一个很有意思的思路,那就是籍GitHub用户通过星星标记感兴趣项目的数目.来观察GitHub中用户最流行的是什么编程语言. 老规矩,让我们用Power BI来分析一下吧.首先从Adereth的博客下载相关数据.然后用Power Query倒入Power Pivot中.对星星数目做透视图非常快就行知道前20流行语言例如以下: 更进一步.我们能够在…
HDU - 6184 C - Counting Stars 题目大意:有n个点,m条边,问有一共有多少个‘structure’也就是满足V=(A,B,C,D) and E=(AB,BC,CD,DA,AC)这样一个图形,类似于四边形中间连接了一条对角线. 如果我们把这个四边形拆分的话,其实就是两个共用一条边的三角形,而在图中就是三元环.求三元环有两种求法,个人感觉这个三元环的时间复杂度很玄学. 第一种一种就是枚举点x,然后枚举和点x相连的y,这时根据y的度,如果y的度小于等于sqrt(m),那么我…
前言 依旧是白嫖账号,只打了一些题/kk 正题 1002 Buying Snacks 题目大意 \(n\)个物品,每个可以买一次也可以不买,如果买需要选择\(1/2\)块钱的,然后也可以相邻两个一起买并且减少一块的花销,求恰好用掉\(m\)块钱的方案. \(1\leq n\leq 10^9,1\leq m\leq 20000,1\leq T\leq 5\) 解题思路 设\(f_{i,j}\)表示\(i\)个物品花\(j\)块钱的方案那么有 \[f_{i,j}=f_{i-1,j}+f_{i-1,j…
在上篇,我了解了基数的基本概念,现在进入Linear Counting算法的学习. 理解颇浅,还请大神指点! http://blog.codinglabs.org/articles/algorithms-for-cardinality-estimation-part-ii.html 它的基本处理方法和上篇中用bitmap统计的方法类似,但是最后要用到一个公式: 说明:m为bitmap总位数,u为0的个数,最后的结果为n的一个估计,且为最大似然估计(MLE). 那么问题来了,最大似然估计是什么东东…
来之不易的2017第一发ac http://poj.org/problem?id=2386 Lake Counting Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 31474   Accepted: 15724 Description Due to recent rains, water has pooled in various places in Farmer John's field, which is repr…
题目: poj 2352 Stars 数星星 题意:已知n个星星的坐标.每个星星都有一个等级,数值等于坐标系内纵坐标和横坐标皆不大于它的星星的个数.星星的坐标按照纵坐标从小到大的顺序给出,纵坐标相同时则按照横坐标从小到大输出. (0 <= x, y <= 32000) 要求输出等级0到n-1之间各等级的星星个数. 分析: 这道题不难想到n平方的算法,即从纵坐标最小的开始搜,每次找它前面横坐标的值比它小的点的个数,两个for循环搞定,但是会超时. 所以需要用一些数据结构去优化,主要是优化找 横坐…
ZOJ3944 People Counting ZOJ3939 The Lucky Week 1.PeopleConting 题意:照片上有很多个人,用矩阵里的字符表示.一个人如下: .O. /|\ (.) 占3*3格子,句号“.”为背景.没有两个人完全重合.有的人被挡住了一部分.问照片上有几个人. 题解: 先弄个常量把3*3人形存起来,然后6个部位依次找,比如现在找头,找到一个头,就把这个人删掉(找这个人的各个部位,如果在该部位位置的不是这个人的身体,就不删),删成句号,疯狂找就行了. 代码:…
#include <stdio.h> #include <malloc.h> #define MAX_STACK 10 ; // define the node of stack typedef struct node { int data; node *next; }*Snode; // define the stack typedef struct Stack{ Snode top; Snode bottom; }*NewStack; void creatStack(NewSt…
1004. Counting Leaves (30)   A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child. Input Each input file contains one test case. Each case starts with a line containing 0 < N < 100,…
Problem Figure 2. The Hamming distance between these two strings is 7. Mismatched symbols are colored red. Given two strings ss and tt of equal length, the Hamming distance between ss and tt, denoted dH(s,t)dH(s,t), is the number of corresponding sym…
Problem A string is simply an ordered collection of symbols selected from some alphabet and formed into a word; the length of a string is the number of symbols that it contains. An example of a length 21 DNA string (whose alphabet contains the symbol…
Stars Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 30496   Accepted: 13316 Description Astronomers often examine star maps where stars are represented by points on a plane and each star has Cartesian coordinates. Let the level of a st…
// uva 11401 Triangle Counting // // 题目大意: // // 求n范围内,任意选三个不同的数,能组成三角形的个数 // // 解题方法: // // 我们设三角巷的最长的长度是c(x),另外两边为y,z // 则由z + y > x得, x - y < z < x 当y = 1时,无解 // 当y = 2时,一个解,这样到y = x - 1 时 有 x - 2个 // 解,所以一共是0,1,2,3....x - 2,一共(x - 2) * (x - 1…
当我们在使用JSONKit处理数据时,直接将文件拉进项目往往会报这两个错“JSONKit   does not support Objective-C Automatic Reference Counting(ARC)”,“ARC forbids Objective-C objects in struct”,这是由于JSONKit库未更新,不支持ARC机制.我们可以参照如下步骤解决:…
有使用JSonKit的朋友,如果遇到“JSonKit does not support Objective-C Automatic Reference Counting(ARC)”这种情况,可参照如下方法: 点击项目根目录->targets->Build Phases->JSONKit.m->添加“-fno-objc-arc”字段,在运行就OK了.…
http://www.lydsy.com/JudgeOnline/problem.php?id=1177 前缀和优化,时间复杂度$O(nm)$ 因为数据不全,快速读入会导致RE,切记! #include<cstdio> #include<cstring> #include<algorithm> using namespace std; const int N = 1503; int in() { int k = 0, fh = 1; char c = getchar()…
Stars in Your Window Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11706   Accepted: 3183 Description Fleeting time does not blur my memory of you. Can it really be 4 years since I first saw you? I still remember, vividly, on the beaut…
Lake Counting Time Limit: 1000MS     Memory Limit: 65536K Total Submissions: 17917     Accepted: 9069 Description Due to recent rains, water has pooled in various places in Farmer John's field, which is represented by a rectangle of N x M (1 <= N <=…