Submission #3234167
Source Code Expand
#include<bits/stdc++.h> using namespace std; void File(){ freopen("ARC92F.in","r",stdin); freopen("ARC92F.out","w",stdout); } #define REP(i,a,b) for(register int i=a;i<=b;++i) #define DREP(i,a,b) for(register int i=a;i>=b;--i) #define mem(a) memset(a,0,sizeof(a)) const int maxn=1000+10; const int maxm=200000+10; vector<int>E[maxn]; int n,m,beg[maxn],len,num[maxn][maxn]; bool can[maxn][maxn],vis[maxn],can1[maxn][maxn]; int vis1[maxn],vis2[maxn],from[maxm],to[maxm]; void dfs(int u,int rt){ vis[u]=1; can[rt][u]=1; int size=E[u].size()-1; REP(i,0,size){ int v=E[u][i]; if(vis[v])continue; dfs(v,rt); } } void dfs1(int u){ vis[u]=1; int size=E[u].size()-1; REP(i,0,size){ int v=E[u][i]; if(vis[v])continue; vis1[v]=num[u][v]; dfs1(v); } } void dfs2(int u){ vis[u]=1; int size=E[u].size()-1; DREP(i,size,0){ int v=E[u][i]; if(vis[v])continue; vis2[v]=num[u][v]; dfs2(v); } } int main(){ //File(); scanf("%d%d",&n,&m); REP(i,1,m){ int u,v; scanf("%d%d",&u,&v); E[u].push_back(v); num[u][v]=++len; from[len]=u; to[len]=v; } REP(i,1,n){ dfs(i,i); mem(vis); } REP(i,1,n){ dfs1(i); mem(vis); dfs2(i); mem(vis); int size=E[i].size()-1; REP(j,0,size){ int v=E[i][j]; if(vis1[v]!=num[i][v] || vis2[v]!=num[i][v]) can1[i][v]=1; } mem(vis1); mem(vis2); } REP(i,1,m){ int u=from[i],v=to[i]; if((can[v][u]^can1[u][v])==0) puts("same"); else puts("diff"); } return 0; }//
Submission Info
Submission Time | |
---|---|
Task | F - Two Faced Edges |
User | vjudge3 |
Language | Bash (GNU bash v4.3.11) |
Score | 0 |
Code Size | 1762 Byte |
Status | RE |
Exec Time | 2 ms |
Memory | 504 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 | RE | 2 ms | 504 KB |
bigcycle_1 | RE | 2 ms | 504 KB |
dag_0 | RE | 2 ms | 504 KB |
dag_1 | RE | 2 ms | 504 KB |
dag_2 | RE | 2 ms | 504 KB |
dag_3 | RE | 2 ms | 504 KB |
dag_4 | RE | 2 ms | 504 KB |
dag_5 | RE | 2 ms | 504 KB |
dag_6 | RE | 2 ms | 504 KB |
dag_7 | RE | 2 ms | 504 KB |
dagex2_0 | RE | 2 ms | 504 KB |
dagex2_1 | RE | 2 ms | 504 KB |
dagex2_2 | RE | 2 ms | 504 KB |
dagex2_3 | RE | 2 ms | 504 KB |
dagex_0 | RE | 2 ms | 504 KB |
dagex_1 | RE | 2 ms | 504 KB |
dagex_2 | RE | 2 ms | 504 KB |
dagex_3 | RE | 2 ms | 504 KB |
example_0 | RE | 2 ms | 504 KB |
example_1 | RE | 2 ms | 504 KB |
example_2 | RE | 2 ms | 504 KB |
maxrand_0 | RE | 2 ms | 504 KB |
maxrand_1 | RE | 2 ms | 504 KB |
sep2_0 | RE | 2 ms | 504 KB |
sep2_1 | RE | 2 ms | 504 KB |
sep2ex_0 | RE | 2 ms | 504 KB |
sep2ex_1 | RE | 2 ms | 504 KB |
sep2ex_2 | RE | 2 ms | 504 KB |
sep2ex_3 | RE | 2 ms | 504 KB |
sep2ex_4 | RE | 2 ms | 504 KB |
sep2ex_5 | RE | 2 ms | 504 KB |
sep2ex_6 | RE | 2 ms | 504 KB |
sep2ex_7 | RE | 2 ms | 504 KB |
sep2ex_8 | RE | 2 ms | 504 KB |
sep2ex_9 | RE | 2 ms | 504 KB |
smallrand_0 | RE | 2 ms | 504 KB |
smallrand_1 | RE | 2 ms | 504 KB |
smallrand_2 | RE | 2 ms | 504 KB |
smallrand_3 | RE | 2 ms | 504 KB |
smallrand_4 | RE | 2 ms | 504 KB |
smallrand_5 | RE | 2 ms | 504 KB |
smallrand_6 | RE | 2 ms | 504 KB |
smallrand_7 | RE | 2 ms | 504 KB |
smallrand_8 | RE | 2 ms | 504 KB |
smallrand_9 | RE | 2 ms | 504 KB |
sparserand_0 | RE | 2 ms | 504 KB |
sparserand_1 | RE | 2 ms | 504 KB |
worst2_0 | RE | 2 ms | 504 KB |
worst2_1 | RE | 2 ms | 504 KB |
worst2_2 | RE | 2 ms | 504 KB |
worst2_3 | RE | 2 ms | 504 KB |
worst_0 | RE | 2 ms | 504 KB |
worst_1 | RE | 2 ms | 504 KB |
worst_2 | RE | 2 ms | 504 KB |
worst_3 | RE | 2 ms | 504 KB |