Cod sursa(job #309215)

Utilizator gigi_becaliGigi Becali gigi_becali Data 29 aprilie 2009 20:59:26
Problema Cutii Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.83 kb
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <map>
#include <hash_map.h>
#define N 100001
#define maxh 2000003
using namespace std;


/*
struct nod
{
    int x, y;
    int v;
    nod *next;
};

nod *aib[maxh];

inline void add(int x, int y)
{
    int h=(x*13+y)%maxh;

    nod *p;

    for(p=aib[h]; p ; p=p->next)
	if(p->x == x && p->y == y)
	{
	    ++p->v;
	    return ;
	}

    p=new nod;
    p->x=x;
    p->y=y;
    p->v=1;
    p->next=aib[h];
    aib[h]=p;
}
*/


map<int, map<int, int> > aib;
int n;

inline void update(int x, int y)
{
    int i, j;
    for(i=x; i <= n; i += i & -i)
	for(j=y; j <= n; j += j & -j)
	//    add(i, j);
	    ++aib[i][j];
}

int main()
{
    srand(time(0));


    n=50000;

    int p, q,i;

    for(i=1;i <= n; ++i)
    {
	p=rand()%n+1;
	q=rand()%n+1;

	update(p,q);
    }

    return 0;
}