QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#406304#8593. Coinxiaolang0 8ms60636kbC++14882b2024-05-07 09:24:142024-05-07 09:24:18

Judging History

你现在查看的是最新测评结果

  • [2024-05-07 09:24:18]
  • 评测
  • 测评结果:0
  • 用时:8ms
  • 内存:60636kb
  • [2024-05-07 09:24:14]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=2e6+5;
vector<int>ed[N]; 
int in[N],tin[N];
int t1[N],t2[N],len1,len2;
int q[N];
int n,m;
void toposort(bool typ){
	int len=0;
	for(int i=1;i<=n;i++){
		int u=((!typ)?i:n+1-i);
		if(!tin[u])q[++len]=u;
	}
	while(len>0){
		int u=q[len--];
		if(!typ)t1[++len1]=u;
		else t2[++len2]=u;
		int lenn=ed[u].size();
		for(int i=0;i<lenn;i++){
			int v=ed[u][((!typ)?i:lenn-1-i)];
			tin[v]--;
			if(!tin[v])q[++len]=v;
		}
	}
}
int ans[N];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		ed[u].push_back(v); 
		in[v]++;
	}
	for(int i=1;i<=n;i++)tin[i]=in[i];
	toposort(0);
	for(int i=1;i<=n;i++)tin[i]=in[i];
	toposort(1);
	for(int i=1;i<=n;i++)if(t1[i]==t2[i])ans[t1[i]]=2;
	for(int i=1;i<=n;i++)cout<<ans[i]-1<<" ";
	cout<<"\n";
	return 0;
} 

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 3
Acceptable Answer
time: 7ms
memory: 58788kb

input:

4 4
2 4
3 1
4 1
2 3

output:

1 1 -1 -1 

result:

points 0.50 -1 correct

Test #2:

score: 3
Acceptable Answer
time: 3ms
memory: 59036kb

input:

6 8
1 5
5 4
6 2
2 5
4 3
6 1
6 5
2 1

output:

1 1 1 1 1 1 

result:

points 0.50 -1 correct

Test #3:

score: 6
Accepted
time: 8ms
memory: 59800kb

input:

2 1
1 2

output:

1 1 

result:

ok ac

Test #4:

score: 3
Acceptable Answer
time: 8ms
memory: 59304kb

input:

6 12
1 5
5 4
6 2
2 5
4 3
6 5
1 5
1 5
2 4
6 3
1 3
4 3

output:

-1 -1 1 1 1 -1 

result:

points 0.50 -1 correct

Test #5:

score: 3
Acceptable Answer
time: 0ms
memory: 60636kb

input:

7 20
1 6
6 3
1 4
1 5
1 7
1 2
1 5
2 3
4 5
7 2
2 4
5 3
6 3
1 3
4 3
7 5
2 6
4 6
7 2
7 5

output:

1 1 1 1 -1 -1 1 

result:

points 0.50 -1 correct

Test #6:

score: 3
Acceptable Answer
time: 7ms
memory: 59940kb

input:

7 20
5 6
1 3
3 6
4 1
7 4
2 5
4 3
2 6
7 5
4 6
2 6
2 1
4 5
1 3
1 5
7 1
7 6
4 1
7 6
3 6

output:

1 -1 -1 -1 -1 1 -1 

result:

points 0.50 -1 correct

Test #7:

score: 0
Wrong Answer
time: 4ms
memory: 59580kb

input:

7 20
7 6
4 5
6 4
3 6
4 1
6 2
3 5
5 2
7 6
1 2
3 6
6 4
7 1
6 1
7 1
4 5
3 6
3 5
4 5
3 1

output:

1 1 -1 1 1 1 -1 

result:

wrong answer wa

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #1:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

0%