Submission #3231438
Source Code Expand
#include<stdio.h> #include<cstring> #include<algorithm> using namespace std; int read() { int x=0,f=1; char ch=getchar(); while(ch<'0' || ch>'9') { if(ch=='-') f=-1; ch=getchar(); } while(ch>='0' && ch<='9') { x=10*x+ch-'0'; ch=getchar(); } return x*f; } const int Maxn=1005; const int Maxm=200005; struct Edge { int u,v,next; } w[Maxm<<1]; int cnt,head[Maxn]; int n,m,vis[Maxn][Maxn]; bool used[Maxm]; void AddEdge(int u,int v) { cnt++; w[cnt].u=u; w[cnt].v=v; w[cnt].next=head[u]; head[u]=cnt; } void dfs(int start,int x) { if(used[x]) return; vis[start][x]++; used[x]=true; for(int i=head[x]; i; i=w[i].next) { dfs(start,w[i].v); } used[x]=false; } void init() { n=read(); m=read(); for(int i=1; i<=m; i++) { int a=read(); int b=read(); AddEdge(a,b); } for(int i=1; i<=n; i++) { memset(used,0,sizeof(used)); dfs(i,i); } } inline bool SSC(int u,int v) { return vis[u][v] && vis[v][u]; } int main() { init(); for(int i=1; i<=m; i++) { int from=w[i].u; int to=w[i].v; if(SSC(from,to)) { if(vis[from][to]==1) { puts("diff"); } else { puts("same"); } } else { if(vis[from][to]>1) { puts("diff"); } else { puts("same"); } } } return 0; } /* 3 3 1 2 1 3 2 3 2 2 1 2 2 1 5 9 3 2 3 1 4 1 4 2 3 5 5 3 3 4 1 2 2 5 */
Submission Info
Submission Time | |
---|---|
Task | F - Two Faced Edges |
User | vjudge5 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1334 Byte |
Status | TLE |
Exec Time | 5255 ms |
Memory | 9344 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 1100 | ||||||
Status |
|
|
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 | 4480 KB |
bigcycle_1 | TLE | 5255 ms | 4480 KB |
dag_0 | TLE | 5255 ms | 2432 KB |
dag_1 | TLE | 5255 ms | 4480 KB |
dag_2 | TLE | 5255 ms | 2432 KB |
dag_3 | TLE | 5255 ms | 4480 KB |
dag_4 | TLE | 5255 ms | 4480 KB |
dag_5 | TLE | 5255 ms | 4480 KB |
dag_6 | TLE | 5255 ms | 2432 KB |
dag_7 | TLE | 5255 ms | 4480 KB |
dagex2_0 | TLE | 5255 ms | 4480 KB |
dagex2_1 | TLE | 5255 ms | 4480 KB |
dagex2_2 | TLE | 5255 ms | 4480 KB |
dagex2_3 | TLE | 5255 ms | 4480 KB |
dagex_0 | TLE | 5255 ms | 4480 KB |
dagex_1 | TLE | 5255 ms | 4480 KB |
dagex_2 | TLE | 5255 ms | 2432 KB |
dagex_3 | TLE | 5255 ms | 4480 KB |
example_0 | AC | 1 ms | 2432 KB |
example_1 | AC | 1 ms | 2432 KB |
example_2 | AC | 1 ms | 2432 KB |
maxrand_0 | TLE | 5255 ms | 4480 KB |
maxrand_1 | TLE | 5255 ms | 4480 KB |
sep2_0 | TLE | 5255 ms | 4480 KB |
sep2_1 | TLE | 5255 ms | 4480 KB |
sep2ex_0 | TLE | 5255 ms | 4480 KB |
sep2ex_1 | TLE | 5255 ms | 4480 KB |
sep2ex_2 | TLE | 5255 ms | 4480 KB |
sep2ex_3 | TLE | 5255 ms | 4480 KB |
sep2ex_4 | TLE | 5255 ms | 4480 KB |
sep2ex_5 | TLE | 5255 ms | 4480 KB |
sep2ex_6 | TLE | 5255 ms | 4480 KB |
sep2ex_7 | TLE | 5255 ms | 4480 KB |
sep2ex_8 | TLE | 5255 ms | 4480 KB |
sep2ex_9 | TLE | 5255 ms | 4480 KB |
smallrand_0 | AC | 703 ms | 2432 KB |
smallrand_1 | AC | 102 ms | 2432 KB |
smallrand_2 | AC | 1 ms | 2432 KB |
smallrand_3 | AC | 1 ms | 2432 KB |
smallrand_4 | AC | 1 ms | 2432 KB |
smallrand_5 | AC | 2155 ms | 2432 KB |
smallrand_6 | AC | 1 ms | 2432 KB |
smallrand_7 | AC | 1 ms | 2432 KB |
smallrand_8 | AC | 1 ms | 2432 KB |
smallrand_9 | AC | 830 ms | 2432 KB |
sparserand_0 | TLE | 5255 ms | 2432 KB |
sparserand_1 | TLE | 5255 ms | 2432 KB |
worst2_0 | AC | 32 ms | 9344 KB |
worst2_1 | TLE | 5255 ms | 4480 KB |
worst2_2 | AC | 30 ms | 9344 KB |
worst2_3 | TLE | 5255 ms | 4480 KB |
worst_0 | TLE | 5255 ms | 4480 KB |
worst_1 | TLE | 5255 ms | 4480 KB |
worst_2 | TLE | 5255 ms | 4480 KB |
worst_3 | TLE | 5255 ms | 4480 KB |