QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#648097 | #5407. 基础图论练习题 | tx344 | 0 | 6ms | 6464kb | C++14 | 1.9kb | 2024-10-17 17:01:40 | 2024-10-17 17:01:42 |
answer
#include<bits/stdc++.h>
#define ll long long
#define Int __int128
#define ld double
#define fi first
#define se second
#define PII pair<int,int>
#define PLI pair<ll,int>
#define PIL pair<int,ll>
#define PLL pair<ll,ll>
#define PLPII pair<ll,PII>
#define Bit bitset<M>
using namespace std;
const int N=5005,Mod=1e9+7;
int Q,n,d[N],d1[N],s[N],c1[N],c2[N],c3[N],ed[N],ans;
bool lk[N][N];
char a[N];
vector<PII>vec;
vector<int>scp[N];
int ID(char x){return x>='0'&&x<='9'?x-'0':x-'A'+10;}
int G(int x){return x*(x-1)/2;}
void Solve()
{
ans=0;
scanf("%d",&n);
for(int i=1;i<=n;i++)d[i]=0;
for(int i=2;i<=n;i++)
{
scanf("%s",a);
for(int j=0;j<(i+2)/4;j++)
{
for(int k=0;k<4;k++)if(j*4+k+1<i)
{
int x=ID(a[j])>>k&1;
lk[i][j*4+k+1]=x,lk[j*4+k+1][i]=!x;
d[i]+=x,d[j*4+k+1]+=!x;
}
}
}
// for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)if(lk[i][j])printf("%d %d\n",i,j);
for(int i=1;i<=n;i++)s[i]=d[i];
sort(s+1,s+n+1);
for(int i=1;i<=n;i++)ed[s[i]]=i;
for(int i=1;i<=n;i++)if(!ed[i])ed[i]=ed[i-1];
for(int i=1;i<=n;i++)
{
s[i]+=s[i-1];
c1[i]=c1[i-1]+(s[i]==G(i));
c2[i]=c2[i-1]+(s[i]-1==G(i));
c3[i]=c3[i-1]+(s[i]+1==G(i));
}
// printf("?%d\n",c1[n]);
// for(int i=1;i<=n;i++)printf("%d ",s[i]);puts("");
// for(int i=1;i<=n;i++)printf("%d ",G(i));puts("");
for(int i=n;i;i--)for(int j=i-1;j;j--)
{
int x=i,y=j,sum=c1[n];
if(lk[x][y])swap(x,y);
if(d[x]>=d[y])sum+=(c2[ed[d[x]]-1]-c2[ed[d[y]-1]])-(c1[ed[d[x]]-1]-c1[ed[d[y]-1]]);
if(d[x]+1<d[y])sum+=(c3[ed[d[y]-1]]-c3[ed[d[x]]-1])-(c1[ed[d[y]-1]]-c1[ed[d[x]]-1]);
// printf("%d %d %d %d %d %d %d\n",x,y,d[x],d[y],ed[d[x]],ed[d[y]],sum);
ans=(ans*2+sum)%Mod;
}
printf("%d\n",ans);
}
int main()
{
#ifndef ONLINE_JUDGE
freopen(".in","r",stdin);
freopen(".out","w",stdout);
#endif
scanf("%d",&Q);
while(Q--)Solve();
fprintf(stderr,"%.15lf\n",(ld)clock()/CLOCKS_PER_SEC);
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 6ms
memory: 6464kb
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:
281603732 13 268435456 371842543 81 0 1983 2 128094058 268435455 719476259 32769 2 719476259 103 2621439 2523 0 719476275 371842543 2097159 40959 34815 2033662 719478307 502774846 719476259 719476259 719476259 63027 268435469 719476259 36863 2121855 719476259 371842543 80 67 167 4718591 268435455 13...
result:
wrong answer 3rd numbers differ - expected: '285212672', found: '268435456'
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%