Submission #3231445


Source Code Expand

#include<iostream>
#include<cstdio>
#include<cstring>
#define maxn 1005
#define maxm 200005
using namespace std;
int n,m; 
struct edge{
	int from;
	int to;
	int next;
}E[maxm];
int sz=0; 
int head[maxn];
void add_edge(int u,int v){
	sz++;
	E[sz].from=u;
	E[sz].to=v;
	E[sz].next=head[u];
	head[u]=sz;
}
int used[maxn];
int route[maxn][maxn];
void dfs(int s,int x){
	used[x]=1;
	route[s][x]++;
	for(int i=head[x];i;i=E[i].next){
		int y=E[i].to;
		if(y==s) continue;
		if(!used[y]&&route[s][y]<2){
			dfs(s,y);
		}
	}
}

int judge(int u,int v){//1为diff,0为same 
	if(route[v][u]>0){//在一个SCC中 
		if(route[u][v]>=2) return 0;
		else return 1; 
	}else{//不在一个SCC中 
		if(route[u][v]>=2) return 1;
		else return 0;
	}
}

int main(){
	scanf("%d %d",&n,&m);
	int u,v;
	for(int i=1;i<=m;i++){
		scanf("%d %d",&u,&v);
		add_edge(u,v);
	}
	for(int i=1;i<=n;i++){
		for(int j=head[i];j;j=E[j].next){
			int y=E[j].to;
			if(route[i][y]<2){
				memset(used,0,sizeof(used));
				dfs(i,y);
			}
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			printf("%d ",route[i][j]);
		}
		printf("\n");
	}
	for(int i=1;i<=m;i++){
		if(judge(E[i].from,E[i].to)) printf("diff\n");
		else printf("same\n");
	}
}

Submission Info

Submission Time
Task F - Two Faced Edges
User vjudge3
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1210 Byte
Status WA
Exec Time 5255 ms
Memory 9472 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:47:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&n,&m);
                      ^
./Main.cpp:50:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d",&u,&v);
                       ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 1100
Status
WA × 3
WA × 45
TLE × 10
Set Name Test Cases
Sample example_0, example_1, example_2
All bigcycle_0, bigcycle_1, dag_0, dag_1, dag_2, dag_3, dag_4, dag_5, dag_6, dag_7, dagex2_0, dagex2_1, dagex2_2, dagex2_3, dagex_0, dagex_1, dagex_2, dagex_3, example_0, example_1, example_2, maxrand_0, maxrand_1, sep2_0, sep2_1, sep2ex_0, sep2ex_1, sep2ex_2, sep2ex_3, sep2ex_4, sep2ex_5, sep2ex_6, sep2ex_7, sep2ex_8, sep2ex_9, smallrand_0, smallrand_1, smallrand_2, smallrand_3, smallrand_4, smallrand_5, smallrand_6, smallrand_7, smallrand_8, smallrand_9, sparserand_0, sparserand_1, worst2_0, worst2_1, worst2_2, worst2_3, worst_0, worst_1, worst_2, worst_3
Case Name Status Exec Time Memory
bigcycle_0 TLE 5255 ms 6528 KB
bigcycle_1 TLE 5255 ms 6528 KB
dag_0 WA 1171 ms 8832 KB
dag_1 WA 2561 ms 9472 KB
dag_2 WA 2579 ms 8832 KB
dag_3 TLE 5255 ms 6528 KB
dag_4 WA 2280 ms 9216 KB
dag_5 WA 2550 ms 9472 KB
dag_6 WA 4437 ms 9088 KB
dag_7 TLE 5255 ms 6528 KB
dagex2_0 WA 2351 ms 9216 KB
dagex2_1 WA 2577 ms 9472 KB
dagex2_2 WA 2411 ms 9216 KB
dagex2_3 WA 2591 ms 9472 KB
dagex_0 WA 2234 ms 9088 KB
dagex_1 WA 2582 ms 9472 KB
dagex_2 WA 2073 ms 9088 KB
dagex_3 WA 2599 ms 9472 KB
example_0 WA 2 ms 2304 KB
example_1 WA 2 ms 2304 KB
example_2 WA 2 ms 2304 KB
maxrand_0 TLE 5255 ms 6528 KB
maxrand_1 TLE 5255 ms 6528 KB
sep2_0 TLE 5255 ms 6528 KB
sep2_1 TLE 5255 ms 6528 KB
sep2ex_0 WA 3896 ms 9472 KB
sep2ex_1 WA 3965 ms 9472 KB
sep2ex_2 WA 3502 ms 9472 KB
sep2ex_3 WA 3503 ms 9472 KB
sep2ex_4 WA 4085 ms 9472 KB
sep2ex_5 WA 4026 ms 9472 KB
sep2ex_6 WA 4720 ms 9472 KB
sep2ex_7 WA 4797 ms 9472 KB
sep2ex_8 TLE 5255 ms 6528 KB
sep2ex_9 TLE 5255 ms 6528 KB
smallrand_0 WA 2 ms 2304 KB
smallrand_1 WA 2 ms 2304 KB
smallrand_2 WA 1 ms 2304 KB
smallrand_3 WA 1 ms 2304 KB
smallrand_4 WA 1 ms 2304 KB
smallrand_5 WA 2 ms 2432 KB
smallrand_6 WA 1 ms 2304 KB
smallrand_7 WA 1 ms 2304 KB
smallrand_8 WA 1 ms 2304 KB
smallrand_9 WA 1 ms 2304 KB
sparserand_0 WA 217 ms 6400 KB
sparserand_1 WA 214 ms 6400 KB
worst2_0 WA 131 ms 8576 KB
worst2_1 WA 347 ms 8704 KB
worst2_2 WA 132 ms 8704 KB
worst2_3 WA 293 ms 8832 KB
worst_0 WA 1886 ms 9344 KB
worst_1 WA 2606 ms 9344 KB
worst_2 WA 592 ms 9088 KB
worst_3 WA 1080 ms 9216 KB