nbut G,C题

orz下死月先。

然后表示离散神马的忘光了。一笔画神马的奇数度的点只有<=2个啊

然后map<node,int>

还有一点就是map是要键类型必须定义<操作符,而且该操作符能够正确的工作,实际上map底层有红黑树实现。根据二叉树的特点重构<(感谢芒果==)

#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
using namespace std;
typedef struct node{
	int x,y;
	bool operator<(const node &b)const
	{
		if(x==b.x)
			return y<b.y;
		else
			return x<b.x;
	}
}node;
int main()
{
	int N;
	map<node,int>a;
	node tmp,tmp1;
	int i,j,k;
	while(~scanf("%d",&N))
	{
		a.clear ();
		for(i=0;i<N;i++)
		{
			scanf("%d%d%d%d",&tmp.x,&tmp.y,&tmp1.x,&tmp1.y);
			a[tmp]++;
			a[tmp1]++;
		}
		int num=0;
		for(map<node,int>::iterator iter=a.begin();iter!=a.end();iter++)
		{

			if(iter->second%2!=0) num++;
		}
		if(num>2) printf("NO\n");
		else printf("YES\n");
	}
	return 0;
}

然后是c题,k哥跟我说是线性覆盖,死月牛说下标操作-, -.

偶就先贴下k哥的代码吧...Orz

#include <iostream>
#include <algorithm>
#include <string>
#include <set>
//#include <map>
#include <queue>
#include <iomanip>
#include <list>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
//#include <ctime>
using namespace std;
#define M 500005
#define N 5000005

struct Region{
	int a, b;
}reg[M];

int seg[N];

int main()
{
	int n, i, m, maxs;
	while (~scanf ("%d", &n))
	{
		maxs = 0;
		for (i = 0; i < n; i++)
		{
			scanf ("%d%d", ®[i].a, ®[i].b);
			if (maxs < reg[i].b) maxs = reg[i].b;
		}
		memset (seg, 0, sizeof(seg));
		for (i = 0; i < n; i++)
		{
			seg[reg[i].a]++;
			seg[reg[i].b+1]--;
		}
		for (i = 1; i <= maxs; i++)
			seg[i] += seg[i-1];
		scanf ("%d", &m);
		while (m--)
		{
			scanf ("%d", &i);
			printf ("%d\n", seg[i]);
		}
	}
	return 0;
}




你可能感兴趣的:(nbut G,C题)