QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#86662 | #5407. 基础图论练习题 | xzzduang | 0 | 0ms | 0kb | C++14 | 2.0kb | 2023-03-10 14:54:04 | 2023-03-10 14:54:05 |
Judging History
answer
#include<iostream>
#include<stdio.h>
#include<ctype.h>
#include<string.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pii pair<int,int>
#define lowbit(x) ((x)&-(x))
#define popcount(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define umap unordered_map
#define all(x) x.begin(),x.end()
#define mk make_pair
#define pb push_back
#define ckmax(x,y) x=max(x,y)
#define ckmin(x,y) x=min(x,y)
#define rep(i,l,r) for(int i=l;i<=r;++i)
#define per(i,r,l) for(int i=r;i>=l;--i)
#define N 5005
using namespace std;
inline int read(){
int x=0,f=0; char ch=getchar();
while(!isdigit(ch)) f|=(ch==45),ch=getchar();
while(isdigit(ch)) x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
return f?-x:x;
}
bool G[N][N];
int n,dfn[N],low[N],vis[N],st[N],top;
char s[N];
const int mo=1e9+7;
inline void red(int &x){x>=mo?x-=mo:0;}
inline int qpow(int x,int b){
int res=1;
for(;b;x=1LL*x*x%mo,b>>=1) if(b&1) res=1LL*res*x%mo;
return res;
}
int res;
void tarjan(int u){
dfn[u]=low[u]=++dfn[0];
vis[u]=1,st[++top]=u;
for(int v=1;v<=n;++v){
if(!G[u][v]) continue;
if(!dfn[v]){
tarjan(v);
ckmin(low[u],low[v]);
}
else if(vis[v]) ckmin(low[u],dfn[v]);
}
if(dfn[u]==low[u]){
res++;
while(st[top]!=u) vis[st[top]]=0,top--;
vis[st[top]]=0;
top--;
}
}
inline int calc(){
dfn[0]=0;
for(int i=1;i<=n;++i) dfn[i]=low[i]=vis[i]=0;
top=res=0;
for(int i=1;i<=n;++i) if(!dfn[i]) tarjan(i);
return res;
}
signed main(){
n=read();
for(int i=2;i<=n;++i){
scanf("%s",s+1);
int len=strlen(s+1);
for(int j=1;j<=len;++j){
int x;
if(!isdigit(s[j])) x=s[j]-'A'+10;
else x=s[j]-'0';
for(int k=0;k<=3;++k){
G[i][4*j+k-3]=((x>>k)&1);
}
}
}
for(int i=1;i<=n;++i){
for(int j=i+1;j<=n;++j) G[i][j]=(!G[j][i]);
}
int ans=0;
for(int i=1;i<=n;++i){
for(int j=1;j<i;++j){
swap(G[i][j],G[j][i]);
red(ans+=1LL*qpow(2,(i-2)*(i-1)/2+j-1)*calc()%mo);
swap(G[i][j],G[j][i]);
}
}
cout<<ans;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Runtime Error
Test #1:
score: 0
Runtime Error
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:
result:
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%