提交记录 28334


用户 题目 状态 得分 用时 内存 语言 代码长度
positive1 1011a. 测测你的五维数点2 Accepted 100 748.025 ms 4468 KB C++ 1.05 KB
提交时间 评测时间
2025-07-10 15:38:25 2025-07-10 15:38:27
#pragma GCC target("popcnt")
#include<algorithm>
using namespace std;

constexpr int maxn=100000,dim=5,B=64,C=8;
typedef unsigned long long ull;

struct bs
{
	ull v[C];
	void set(unsigned i){v[i/B]|=1ull<<i%B;}
	void andeq(const bs&rhs)
	{
#pragma GCC unroll C
		for(int i=0;i<C;i++) v[i]&=rhs.v[i];
	}
	unsigned cnt()
	{
		unsigned res=0;
#pragma GCC unroll C
		for(int i=0;i<C;i++) res+=__builtin_popcountll(v[i]);
		return res;
	}
}pre[dim][B*C+1];

unsigned seq[B*C+1];
bs *ptr[dim][maxn];

void count_5d(int n,const unsigned *x[5],unsigned *out)
{
	for(int i=0;i<maxn;i+=B*C)
	{
		int r=min(i+B*C,maxn);
		seq[r-i]=-1;
		for(int j=0;j<dim;j++)
		{
			for(int k=i;k<r;k++) seq[k-i]=(x[j][k]+1)*B*C+k-i;
			sort(seq,seq+r-i);
			bs *p=pre[j];
			for(int k=0,it=0;k<maxn;k++)
			{
				if(seq[it]/(B*C)==1u*k)
				{
					*(p+1)=*p;
					p++;
					do p->set(seq[it++]%(B*C)); while(seq[it]/(B*C)==1u*k);
				}
				ptr[j][k]=p;
			}
		}
		for(int j=0;j<maxn;j++)
		{
			bs tmp=*ptr[0][x[0][j]];
			for(int k=1;k<dim;k++) tmp.andeq(*ptr[k][x[k][j]]);
			out[j]+=tmp.cnt();
		}
	}
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #1748.025 ms4 MB + 372 KBAcceptedScore: 100


Judge Duck Online | 评测鸭在线
Server Time: 2025-07-13 21:49:18 | Loaded in 0 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠