Submission #3235300
Source Code Expand
#include <bits/stdc++.h> using namespace std; //using pi = pair<int, int>; const int MAXN = 1005; const int MAXM = 200005; vector<int> gph[MAXN]; int adj[MAXN][MAXN], vis[MAXN]; int n, m; int s[MAXM], e[MAXM]; void dfs(int r, int v){ vis[v] = 1; adj[r][v]++; int cnt=gph[v].size(); for(int it=0;it<cnt;it++){ int i=gph[v][it]; if(i == r) continue; if(!vis[i] && adj[r][i] < 2){ dfs(r, i); } } } int main(){ cin >> n >> m; for(int i=0; i<m; i++){ scanf("%d %d",&s[i],&e[i]); gph[s[i]].push_back(e[i]); } for(int i=1; i<=n; i++){ int cnt=gph[i].size(); for(int it=0;it<cnt;it++){ int j=gph[i][it]; if(adj[i][j] < 2){ memset(vis, 0, sizeof(vis)); dfs(i, j); } } } // for(int i=1;i<=n;i++){ // for(int j=1;j<=n;j++){ // printf("%d ",adj[i][j]); // } // printf("\n"); // } for(int i=0; i<m; i++){ if(adj[e[i]][s[i]] == 0){ puts(adj[s[i]][e[i]] > 1 ? "diff" : "same"); } else{ puts(adj[s[i]][e[i]] > 1 ? "same" : "diff"); } } }
Submission Info
Submission Time | |
---|---|
Task | F - Two Faced Edges |
User | birchtree |
Language | C++14 (GCC 5.4.1) |
Score | 1100 |
Code Size | 1065 Byte |
Status | AC |
Exec Time | 994 ms |
Memory | 8192 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:28:29: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d %d",&s[i],&e[i]); ^
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 1100 / 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 | AC | 540 ms | 7936 KB |
bigcycle_1 | AC | 537 ms | 7936 KB |
dag_0 | AC | 232 ms | 6016 KB |
dag_1 | AC | 455 ms | 7936 KB |
dag_2 | AC | 277 ms | 5888 KB |
dag_3 | AC | 516 ms | 7936 KB |
dag_4 | AC | 411 ms | 7424 KB |
dag_5 | AC | 456 ms | 7936 KB |
dag_6 | AC | 413 ms | 7168 KB |
dag_7 | AC | 515 ms | 7936 KB |
dagex2_0 | AC | 427 ms | 7424 KB |
dagex2_1 | AC | 469 ms | 7936 KB |
dagex2_2 | AC | 446 ms | 7552 KB |
dagex2_3 | AC | 471 ms | 7936 KB |
dagex_0 | AC | 397 ms | 7296 KB |
dagex_1 | AC | 473 ms | 7936 KB |
dagex_2 | AC | 392 ms | 7168 KB |
dagex_3 | AC | 479 ms | 7936 KB |
example_0 | AC | 1 ms | 256 KB |
example_1 | AC | 1 ms | 256 KB |
example_2 | AC | 1 ms | 256 KB |
maxrand_0 | AC | 529 ms | 7808 KB |
maxrand_1 | AC | 528 ms | 7808 KB |
sep2_0 | AC | 537 ms | 7936 KB |
sep2_1 | AC | 538 ms | 7936 KB |
sep2ex_0 | AC | 407 ms | 8064 KB |
sep2ex_1 | AC | 409 ms | 8064 KB |
sep2ex_2 | AC | 530 ms | 7808 KB |
sep2ex_3 | AC | 540 ms | 7808 KB |
sep2ex_4 | AC | 739 ms | 8192 KB |
sep2ex_5 | AC | 738 ms | 8192 KB |
sep2ex_6 | AC | 932 ms | 7808 KB |
sep2ex_7 | AC | 937 ms | 7936 KB |
sep2ex_8 | AC | 986 ms | 7808 KB |
sep2ex_9 | AC | 994 ms | 7808 KB |
smallrand_0 | AC | 1 ms | 384 KB |
smallrand_1 | AC | 1 ms | 384 KB |
smallrand_2 | AC | 1 ms | 256 KB |
smallrand_3 | AC | 1 ms | 256 KB |
smallrand_4 | AC | 1 ms | 384 KB |
smallrand_5 | AC | 1 ms | 384 KB |
smallrand_6 | AC | 1 ms | 256 KB |
smallrand_7 | AC | 1 ms | 384 KB |
smallrand_8 | AC | 1 ms | 256 KB |
smallrand_9 | AC | 1 ms | 384 KB |
sparserand_0 | AC | 79 ms | 4480 KB |
sparserand_1 | AC | 78 ms | 4480 KB |
worst2_0 | AC | 59 ms | 7168 KB |
worst2_1 | AC | 68 ms | 7296 KB |
worst2_2 | AC | 59 ms | 7040 KB |
worst2_3 | AC | 66 ms | 7040 KB |
worst_0 | AC | 194 ms | 8064 KB |
worst_1 | AC | 249 ms | 8192 KB |
worst_2 | AC | 94 ms | 7424 KB |
worst_3 | AC | 130 ms | 7552 KB |