QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#86784 | #5407. 基础图论练习题 | Cring | 0 | 129ms | 101692kb | C++20 | 1.9kb | 2023-03-10 21:55:47 | 2023-03-10 21:55:52 |
Judging History
answer
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define op(x) ((x&1)?x+1:x-1)
#define odd(x) (x&1)
#define even(x) (!odd(x))
#define lc(x) (x<<1)
#define rc(x) (lc(x)|1)
#define lowbit(x) (x&-x)
#define mp(x,y) make_pair(x,y)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
using namespace std;
const int MAXN=5010,mod=1e9+7;
const int MAXM=MAXN*MAXN,LIM=2.5e7;
typedef vector<int> vec;
void add(int& x,int y){x=(x+y)%mod;}
int n,pw[MAXM],ans;
int G[MAXN][MAXN];
int C(int n){return n*(n-1)/2;}
int deg[MAXN],rk[MAXN];
int pre[MAXN],suf[MAXN],sum[MAXN],ed[MAXN];
void ok(int i,int j,int val){
if(i<j)swap(i,j);
int e=(i-1)*(i-2)/2 + (j-1);
add(ans,1ll*val*pw[e]%mod);
}
void solve(int u){
deg[u]--;
iota(rk+1,rk+1+n,1);
sort(rk+1,rk+1+n,[&](int x,int y){return deg[x] < deg[y];});
rep(i,1,n){
sum[i]=sum[i-1] + deg[rk[i]];
pre[i]=pre[i-1] + (sum[i]==C(i));
}
per(i,n,1)suf[i]=suf[i+1] + (sum[i]==C(i)-1);
int cur=0;
rep(i,0,n){
while(cur+1 <= n && deg[rk[cur+1]]==i)cur++;
ed[i]=cur;
}
rep(v,1,n)if(G[u][v]){
int val=deg[v];
ok(u,v,pre[ed[val]-1] + suf[ed[val]]);
}
deg[u]++;
}
int main(){
ios::sync_with_stdio(false);
pw[0]=1;
rep(i,1,LIM)pw[i]=pw[i-1]*2%mod;
int T;cin>>T;
while(T--){
ans=0;
cin>>n;
rep(i,1,n-1){
string s;
cin>>s;
int len=s.length();
s=" "+s;
rep(j,1,len){
char ch=s[j];
int num;
if(isdigit(ch))num=ch-'0';
else num=10 + (ch-'A');
rep(k,0,3){
if(num>>k&1){
G[i+1][4*j+k-3]=1;
}else if(i+1 > 4*j+k-3){
G[4*j+k-3][i+1]=1;
}
}
}
}
rep(u,1,n)deg[u]=0;
rep(u,1,n)rep(v,1,n)if(G[u][v])deg[u]++;
rep(u,1,n)solve(u);
cout<<ans<<"\n";
rep(i,1,n)rep(j,1,n)G[i][j]=0;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 129ms
memory: 101692kb
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 20 553648127 743685086 210 0 4029 5 805375997 805306365 158429019 131086 6 158429275 312 8913020 6615 0 158428779 743685086 6291461 139388 133116 7308286 158430811 308081204 158428771 158428763 158428763 163525 74003971 158429787 135164 8462460 158428763 743685086 246 210 345 9963517 80530...
result:
wrong answer 2nd numbers differ - expected: '13', found: '20'
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%