QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#647907#5407. 基础图论练习题PatrickStar0 11ms4248kbC++141.9kb2024-10-17 16:09:212024-10-17 16:09:22

Judging History

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

  • [2024-10-17 16:09:22]
  • 评测
  • 测评结果:0
  • 用时:11ms
  • 内存:4248kb
  • [2024-10-17 16:09:21]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int mod = 1e9+7;
int t, n, sum[5005], sum0[5005], sum1[5005], sum2[5005];
bool book[5005][5005];
int place[5005], L[5005], R[5005];
struct e{
	int i, u;
}a[5005];
bool cmp(e x, e y) {
	return x.u<y.u;
}
int main() {
	scanf("%d", &t);
	for (int zqw=1;zqw<=t;zqw++) {
		scanf("%d", &n);
		for (int p=1;p<=n;p++) {
			for (int k=1;k<=n;k++) {
				book[p][k] = 0;
			}
		}
		for (int p=2;p<=n;p++) {
			for (int k=1;k<=(p+2)/4;k++) {
				char c;
				cin>>c;
				int u;
				if (c<='9') u = c-'0';
				else u = 10+c-'A';
				for (int i=0;i<=3;i++) {
					if ((u>>i)&1) book[p][4*k+i-3] = 1;
				}
			}
		}
		for (int p=1;p<=n;p++) {
			for (int k=1;k<p;k++) {
				if (!book[p][k]) book[k][p] = 1;
			}
		}
		for (int p=1;p<=n;p++) {
			int u = 0;
			for (int k=1;k<=n;k++) {
				if (book[p][k]) u++;
			}
			a[p] = {p, u};
		}
		stable_sort(a+1, a+n+1, cmp);
		for (int p=1;p<=n;p++) {
			place[a[p].i] = p;
			sum[p] = sum[p-1]+a[p].u;
		}
		for (int p=1;p<=n;p++) {
			sum[p]-=p*(p-1)/2;
			sum0[p] = sum0[p-1]+(sum[p]==0);
			sum1[p] = sum1[p-1]+(sum[p]==1);
			sum2[p] = sum2[p-1]+(sum[p]==-1);
		}
		for (int p=1;p<=n;p++) {
			int i = p;
			while (i<=n&&a[i].u==a[p].u) {
				i++;
			}
			i--;
			for (int k=p;k<=i;k++) {
				L[k] = p;
				R[k] = i;
			}
			p = i;
		}
		ll ans = 0, o = 1;
		for (int p=1;p<=n;p++) {
			for (int k=1;k<p;k++) {
				int i, j;
				if (!book[p][k]) i = L[place[k]], j = R[place[p]];
				else i = L[place[p]], j = R[place[k]];
				if (i==j+1&&a[i].u==a[j].u+1) ans = (ans+o*sum0[n])%mod;
				else if (i<j) ans = (ans+o*(sum0[n]-(sum0[j-1]-sum0[i-1])+(sum1[j-1]-sum1[i-1]))%mod)%mod;
				else ans = (ans+o*(sum0[n]-(sum0[i-1]-sum0[j-1])+(sum2[i-1]-sum2[j-1])));
				o = o*2%mod;
			}
		}
		printf("%lld\n", ans);
	}
	return 0;
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 11ms
memory: 4248kb

input:

10000
100
1
2
2
8
C0
F0
27
78
AE1
C01
511
D87
EF20
3873
2742
73D0
DC9B0
FB2A3
9C011
9B4E0
95DC00
A7B980
F43531
6A6245
5347BE0
1A6C8A1
88E46D6
64CF3AE
D25F63C1
C894E4C3
1C0AFD73
EC1C3F9A
087CE17C0
22149A380
B28038AF1
B9CA21C7F
D78F5307C1
49045489A2
72C4DE6FD1
7713F40D05
EEE8878EEC1
310E62812B1
DA9D5B...

output:

1281603739
13
285212672
371842543
84
0
1983
2
268505087
268435455
719476515
32785
2
719476771
123
2621567
2523
0
1719476282
371842543
2097159
41087
34815
3113984
719478307
502774846
719476267
719476259
719476259
65224
268697613
719477283
36863
2171007
719476259
371842543
120
84
219
5769215
268435455...

result:

wrong answer 1st numbers differ - expected: '281603732', found: '1281603739'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #1:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

0%

Subtask #5:

score: 0
Skipped

Dependency #1:

0%