QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#86672 | #5407. 基础图论练习题 | oier12345 | Compile Error | / | / | C++14 | 1.6kb | 2023-03-10 15:28:13 | 2023-03-10 15:28:16 |
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-10 15:28:16]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-03-10 15:28:13]
- 提交
answer
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int n,ans;
char a[5005];
int id[5005];
int pos[5005];
vector<int>g[5005];
bool cmp(int i,int j) {
return g[i].size()>g[j].size();
}
int p[25000005]= {1};
int sum[5005],s[5005];
long long get(int i,int j) {
if(i<j)swap(i,j);
return p[(i-2)*(i-1)/2+j-1];
}
int cnt=1,l[5005],r[5005],b[5005],len[5005];
void calc(int l,int r) {
for(int i=l; i<r; i++) {
s[i+1]=s[i]+(sum[i]+1==i*(n-i));
}
for(int i=l; i<=r; i++) {
for(int x:g[id[i]]) {
int j=pos[x];
if(j>r) {
if(b[i]+1==b[j]&&len[b[i]]==1&&len[b[j]]==1) {
ans=(ans+get(id[i],x)*cnt%mod)%mod;
} else {
ans=(ans+get(id[i],x)*(cnt+b[i]-b[j])%mod)%mod;
}
}
if(j<l||j>r)continue;
if(j>i)ans=(ans+get(id[i],x)*cnt%mod)%mod;
else ans=(ans+get(id[i],x)*(cnt+s[i]-s[j])%mod)%mod;
}
}
}
int main() {
scanf("%d",&n);
for(int i=1; i<=n*n; i++) {
p[i]=p[i-1]*2%mod;
}
for(int i=2; i<=n; i++) {
scanf("\n%s",a);
int m=strlen(a);
for(int j=0; j<m; j++) {
int x=(a[j]>='0'&&a[j]<='9'?a[j]-'0':a[j]-'A'+10);
for(int k=1; k<=4&&j*4+k<i; k++) {
if(x&1) {
g[i].push_back(j*4+k);
} else {
g[j*4+k].push_back(i);
}
x>>=1;
}
}
}
for(int i=1; i<=n; i++)id[i]=i;
sort(id+1,id+1+n,cmp);
int last=0;
for(int i=1; i<=n; i++) {
b[i]=cnt;
pos[id[i]]=i;
sum[i]=sum[i-1]+g[id[i]].size()-i+1;
if(sum[i]==i*(n-i)) {
len[cnt]=i-last;
l[cnt]=last+1;
r[cnt]=i;
cnt++;
last=i;
}
}
cnt--;
for(int i=1; i<=cnt; i++) {
calc(l[i],r[i]);
}
printf("%d",ans);
return 0;
}
Details
answer.code: In function ‘int main()’: answer.code:40:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 40 | scanf("%d",&n); | ~~~~~^~~~~~~~~ answer.code:45:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 45 | scanf("\n%s",a); | ~~~~~^~~~~~~~~~ /tmp/ccyURuH1.s: Assembler messages: /tmp/ccyURuH1.s: Fatal error: can't write 50 bytes to section .text of /tmp/ccR2XEg2.o: 'File too large' /tmp/ccyURuH1.s: Fatal error: can't close /tmp/ccR2XEg2.o: No space left on device