QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#830388 | #8943. Challenge Matrix Multiplication | QBF | WA | 0ms | 32684kb | C++14 | 584b | 2024-12-24 19:18:47 | 2024-12-24 19:18:57 |
Judging History
answer
#include<bits/stdc++.h>
#define ci const int
using namespace std;ci N=1e6+5;int n,m,d[N],A[N],s[N],V[N];vector<int>g[N],c;void D(ci x){c.push_back(x);if(d[x]<0){++d[x];return;}D(g[x][s[x]++]);}int main(){cin>>n>>m;for(int x,y;m;--m)cin>>x>>y,g[x].push_back(y),++d[x],--d[y];for(int i=1;i<=n;++i)while(d[i]>0){--d[i],D(i);for(int j=1;j<=n;++j)V[j]=0;int T=0;for(int k=0;k<c.size();++k){ci x=c[k];queue<int>q;q.push(x),V[x]=1;while(!q.empty()){++T;ci x=q.front();q.pop();V[x]=1;for(int y:g[x])if(!V[y])q.push(y),V[y]=1;}A[x]=T;}c.clear();}for(int i=1;i<=n;++i)cout<<max(A[i],1)<<' ';}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 32684kb
input:
4 6 1 3 2 3 2 4 1 2 1 3 1 3
output:
4 3 5 4
result:
wrong answer 3rd numbers differ - expected: '1', found: '5'