QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#829680 | #8943. Challenge Matrix Multiplication | QBF | Compile Error | / | / | C++14 | 1.6kb | 2024-12-24 12:03:45 | 2024-12-24 12:03:47 |
Judging History
answer
#include<bits/stdc++.h>
#define fo(i,l,r) for(int i=(l);i<=(r);++i)
#define fd(i,l,r) for(int i=(l);i>=(r);--i)
#define fu(i,l,r) for(int i=(l);i<(r);++i)
#define pi pair<int,int>
#define eb emplace_back
#define vi vector<int>
#define mp make_pair
#define ll long long
using namespace std;
const int N=1e6+7,M=123;
int n,m,deg[N*60],pd[N*60],d[N*60],ans[N*60],h,t,q[N*60],mx,bh[N*60],o;
ll b[N*60];
map<ll,int>f[N];
vi p[N];
int tot,to[N*60],head[N*60],nx[N*60];
void add(int x,int y){to[++tot]=y;nx[tot]=head[x];head[x]=tot;}
void bfs()
{
h=1;t=0;
fo(i,1,n) d[i]=-1;
fo(i,1,n) if(!deg[i])
{
if(pd[i]) q[++t]=i,d[i]=0;
else ans[i]=1;
}
while(h<=t)
{
int x=q[h];h++;
for(int i=head[x],j;i;i=nx[i])
{
j=to[i];
deg[j]--;
if(!deg[j]) d[j]=d[x]+1,q[++t]=j;
}
}
}
int calc(int x,ll y)
{
if(!y) return 0;
if(f[x].count(y)) return f[x][y];
ll s=0;int sum=0;
fu(i,0,60) if((y>>i)&1) s|=b[p[x][i]],sum+=p[x][i]<=n;
return f[x][y]=calc(x+1,s)+sum;
}
int main()
{
scanf("%d%d",&n,&m);
fo(i,1,m)
{
int x,y;scanf("%d%d",&x,&y);
add(x,y);deg[y]++;pd[x]=1;
}
bfs();
fo(i,1,n) if(d[i]!=-1) p[d[i]].push_back(i),mx=max(mx,d[i]);
o=n;
fd(i,mx,0)
{
int cnt=0;
for(int x:p[i]) bh[x]=cnt++;
}
fo(i,1,n)
{
for(int j=head[i],k;j;j=nx[j])
{
k=to[j];
if(d[i]+1==d[k])
{
b[i]|=1ll<<bh[k];
continue;
}
int lt=i;
fo(l,d[i]+1,d[k]-1) o++,b[lt]|=1ll<<(int)p[l].size(),p[l].push_back(o),lt=o;
b[lt]|=1ll<<bh[k];
}
}
fd(i,mx,0)
{
for(int x:p[i])
ans[x]=calc(i,1ll<<bh[x]);
}
fo(i,1,n) printf("%d ",ans[i]);
}
Details
answer.code: In function ‘int main()’: answer.code:48:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 48 | scanf("%d%d",&n,&m); | ~~~~~^~~~~~~~~~~~~~ answer.code:51:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 51 | int x,y;scanf("%d%d",&x,&y); | ~~~~~^~~~~~~~~~~~~~ /tmp/ccES7bhZ.o: in function `bfs()': answer.code:(.text+0x4c4): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccES7bhZ.o answer.code:(.text+0x50a): relocation truncated to fit: R_X86_64_PC32 against symbol `deg' defined in .bss section in /tmp/ccES7bhZ.o answer.code:(.text+0x511): relocation truncated to fit: R_X86_64_PC32 against symbol `pd' defined in .bss section in /tmp/ccES7bhZ.o /tmp/ccES7bhZ.o: in function `calc(int, long long)': answer.code:(.text+0x742): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccES7bhZ.o /tmp/ccES7bhZ.o: in function `main': answer.code:(.text.startup+0x9): relocation truncated to fit: R_X86_64_PC32 against symbol `m' defined in .bss section in /tmp/ccES7bhZ.o answer.code:(.text.startup+0x10): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccES7bhZ.o answer.code:(.text.startup+0x41): relocation truncated to fit: R_X86_64_PC32 against symbol `m' defined in .bss section in /tmp/ccES7bhZ.o answer.code:(.text.startup+0x7f): relocation truncated to fit: R_X86_64_PC32 against symbol `deg' defined in .bss section in /tmp/ccES7bhZ.o answer.code:(.text.startup+0x8e): relocation truncated to fit: R_X86_64_PC32 against symbol `pd' defined in .bss section in /tmp/ccES7bhZ.o answer.code:(.text.startup+0xe6): relocation truncated to fit: R_X86_64_PC32 against symbol `m' defined in .bss section in /tmp/ccES7bhZ.o answer.code:(.text.startup+0x105): additional relocation overflows omitted from the output collect2: error: ld returned 1 exit status