QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#830388#8943. Challenge Matrix MultiplicationQBFWA 0ms32684kbC++14584b2024-12-24 19:18:472024-12-24 19:18:57

Judging History

This is the latest submission verdict.

  • [2024-12-24 19:18:57]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 32684kb
  • [2024-12-24 19:18:47]
  • Submitted

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'