QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#84888#5407. 基础图论练习题yyyyxh0 11ms5104kbC++141.5kb2023-03-06 20:40:182023-03-06 20:40:42

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-06 20:40:42]
  • 评测
  • 测评结果:0
  • 用时:11ms
  • 内存:5104kb
  • [2023-03-06 20:40:18]
  • 提交

answer

#include <cstdio>
#include <bitset>
using namespace std;
const int N=5003;
int mp[200];
char str[N];
int deg[N];
bitset<N> g[N];
int buc[N],seq[N],pos[N];
int s[N],s1[N],s2[N],s3[N];
int lf[N],rg[N];
void solve(){
	int n;
	scanf("%d",&n);
	for(int i=2;i<=n;++i){
		scanf("%s",str);
		int p=0;
		for(int j=0;j<((i+2)>>2);++j)
			for(int t=0;t<4;++t){
				if(++p>=i) break;
				if(mp[str[j]]>>t&1){
					g[i].set(p);
					++deg[p];
				}
				else ++deg[i];
			}
	}
	for(int i=0;i<=n;++i) buc[i]=0;
	for(int i=1;i<=n;++i) ++buc[deg[i]];
	for(int i=1;i<=n;++i) buc[i]+=buc[i-1];
	for(int i=n;i;--i) seq[buc[deg[i]]--]=deg[i];
	for(int i=1;i<=n;++i) rg[seq[i]]=i;
	for(int i=n;i;--i) lf[seq[i]]=i;
	int sum=0;
	for(int i=1,cur=0;i<=n;++i){
		cur+=seq[i];
		s1[i]=s1[i-1];
		s2[i]=s2[i-1];
		s3[i]=s3[i-1];
		if(cur==(i*(i-1)>>1)) ++s1[i],++sum;
		if(cur==(i*(i-1)>>1)+1) ++s2[i];
		if(cur==(i*(i-1)>>1)-1) ++s3[i];
	}
	int ans=0;
	for(int i=n;i;--i)
		for(int j=i-1;j;--j){
			int res=sum,x,y;
			if(g[i][j]) x=deg[i],y=deg[j];
			else x=deg[j],y=deg[i];
			if(x==y-1){
				ans=(ans*2ll+res)%1000000007;
				continue;
			}
			x=rg[x]-1;y=lf[y]-1;
			if(x<y) res+=s2[y]-s2[x]+s1[x]-s1[y];
			else res=s3[x]-s3[y]+s1[y]-s1[x];
			ans=(ans*2ll+res)%1000000007;
		}
	printf("%d\n",ans);
	for(int i=1;i<=n;++i){
		deg[i]=0;
		for(int j=1;j<i;++j) g[i].reset(j);
	}
}
int main(){
	for(int i=0;i<10;++i) mp[i+'0']=i;
	for(int i=10;i<16;++i) mp[i+'A'-10]=i;
	int tc;
	scanf("%d",&tc);
	while(tc--) solve();
	return 0;
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

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

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:

312013799
13
51190250
19829676
44
0
1983
2
331163786
165706095
238525407
20859
2
126379431
35
2127466
2488
0
659741276
338567950
1971364
45361
5418
1705235
774979596
46879686
838917923
10760654
28617602
104304
540557955
551226653
55584
7035176
929701396
864824931
22
44
11
367121
195244732
13
4400746...

result:

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

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%