QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#212112#5407. 基础图论练习题BINYUCompile Error//C++981.8kb2023-10-13 09:08:332023-10-13 09:08:33

Judging History

你现在查看的是最新测评结果

  • [2023-10-13 09:08:33]
  • 评测
  • [2023-10-13 09:08:33]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod = 1e9 + 7;
int t,n,e[5005][5005],out[5005];
int sum[5005],en[5005],cnt1[5005],cnt[5005],ans[5005][5005];
ll f[12500005] = {1},Ans;
char s[5005];
struct node
{
	int out,id;
}a[5005];
bool cmp(node a,node b)
{
	return a.out < b.out;
}
int main()
{
	ios::sync_with_stdio(false);
	cout.tie(0);
	cin.tie(0);
	cin>>t;
	for(int i = 1;i <= 12500000;i++)
		f[i] = f[i - 1] * 2 % mod;
	while(t--)
	{
		cin>>n;
		for(int i = 1;i <= n;i++)
			a[i].out = out[i] = 0,a[i].id = i;
		for(int i = 2;i <= n;i++)
		{
			cin>>s;
			for(int j = 1;j < i;j++)
			{
				e[i][j] = e[j][i] = 0;
				int now;
				if(s[(j - 1) / 4] >= 'A')
					now = s[(j - 1) / 4] - 'A' + 10;
				else now = s[(j - 1) / 4] - '0';
				if(now & (1 << ((j - 1) % 4)))
					e[i][j] = 1,a[i].out++,out[i]++;
				else 
					e[j][i] = 1,a[j].out++,out[j]++;
			}
		}
		sort(a + 1,a + n + 1,cmp);
		for(int i = 1;i <= n;i++)
		{
			for(int j = a[i - 1].out;j < a[i].out;j++)
				en[j] = i - 1;
			sum[i] = sum[i - 1] + a[i].out;
			if(sum[i] == i * (i - 1) / 2)
				cnt[i] = cnt[i - 1] + 1;
			else cnt[i] = cnt[i - 1];
			if(sum[i] == i * (i - 1) / 2 + 1)
				cnt1[i] = cnt1[i - 1];
			else cnt1[i] = cnt1[i - 1];
		}
		for(int i = 1;i <= n;i++)
			for(int j = 1;j <= n;j++)
			{
				if(!e[i][j])continue;
				if(out[i] > out[j] + 1)
					ans[j][i] = ans[i][j] = cnt[n] - (cnt[en[out[i] - 1]] - cnt[en[out[j]] - 1]);
				else if(out[i] <= out[j])
					ans[j][i] = ans[i][j] = cnt[n] + (cnt1[en[out[j]] - 1] - cnt1[en[out[i] - 1]]);
				else ans[j][i] = ans[i][j] = cnt[n];
			}
		Ans = 0;
		for(int i = 2;i <= n;i++)
			for(int j = 1;j < i;j++)
				(Ans += f[(i - 2) * (i - 1) / 2 + j - 1] * ans[i][j] % mod) % mod;
		cout<<Ans<<endl;
	}
}

詳細信息

/tmp/cctChK97.s: Assembler messages:
/tmp/cctChK97.s: Fatal error: can't write 10 bytes to section .text of /tmp/cc9fe3U6.o: 'File too large'
/tmp/cctChK97.s: Fatal error: can't close /tmp/cc9fe3U6.o: File too large