您当前的位置: 首页 >  蓝桥杯

先求一个导

暂无认证

  • 1浏览

    0关注

    291博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

2018年第九届蓝桥杯 省赛 编程题题解

先求一个导 发布时间:2022-04-08 16:30:01 ,浏览量:1

题目 A.递增三元组

题意: 给定三个数组,求有多少个三元组,满足Ai < Bj < Ck. 思路: 枚举中间那个数组,二分找即可。 (做过一次还是做错,太逆天了,每次都下意识枚举第一个数组,但是显然不满足单调性.) 时间复杂度: O(nlogn) 代码:

#include
#include
#include
#include
#include
#include
using namespace std;
#define mem(a,x) memset(a,x,sizeof(a))
#define fir(i,a,b) for(int i=a;i>n;
	a = vector(n); b = vector(n); c = vector(n);
	for(int i=0;i>a[i];
	for(int i=0;i>b[i];
	for(int i=0;i>c[i];
	sort(a.begin(),a.end()); sort(b.begin(),b.end()); sort(c.begin(),c.end());
	for(int i=0;iy;
	if(x == y && x >= 0)
	{
	    ans = 4ll*(x)*(x);
	}
	else
	{
		ll mx = max(abs(x),abs(y));
		ll n = mx;
	    ans = 4ll*(n) * (n);
		if(x == n)
		{
			ans += n-y;
		}
		else if(y==-n)
		{
			ans += 2*n;
			ans += n-x;
		}
		else if(y==n)
		{
			ans -= n-x;
		}
		else if(x==-n)
		{
			ans -= 2*n;
			ans -= n-y;
		}
	}
	cout>m>>k;
	for(int i=0;i>id>>x;
		va[x].push_back(id);
	}
	for(int i=0;i>k;
	for(int i=0;i>id>>x;
		va[x].push_back(id);
	}
	for(int i=0;i            
关注
打赏
1662037414
查看更多评论
0.0405s