Submission #180675
Source Code Expand
#include <stdio.h> #include <string.h> #define NODE_MAX 128 #define INF 100000000 typedef struct edge_t_tag { int max; int next; struct edge_t_tag* pair; } edge_t; int edge_num[NODE_MAX]; edge_t edges[NODE_MAX][NODE_MAX]; char visited[NODE_MAX]; int get_one_flow(int now,int goal,int limit) { int i; if(now==goal)return limit; if(visited[now])return 0; visited[now]=1; for(i=0;i<edge_num[now];i++) { int now_flow; if(edges[now][i].max<=0)continue; now_flow=get_one_flow(edges[now][i].next,goal, edges[now][i].max<limit?edges[now][i].max:limit); if(now_flow>0) { edges[now][i].max-=now_flow; edges[now][i].pair->max+=now_flow; return now_flow; } } return 0; } int get_max_flow(int s,int g) { int result=0; while(1) { int now; memset(visited,0,sizeof(visited)); now=get_one_flow(s,g,INF); if(now==0)break; result+=now; } return result; } void flow_init(void) { memset(edge_num,0,sizeof(edge_num)); } void flow_add_edge(int s,int t,int max) { edges[s][edge_num[s]].max=max; edges[s][edge_num[s]].next=t; edges[s][edge_num[s]].pair=&edges[t][edge_num[t]]; edge_num[s]++; edges[t][edge_num[t]].max=0; edges[t][edge_num[t]].next=s; edges[t][edge_num[t]].pair=&edges[s][edge_num[s]]; edge_num[t]++; } int main(void) { int N,G,E; int i; scanf("%d%d%d",&N,&G,&E); flow_init(); for(i=0;i<G;i++) { int p; scanf("%d",&p); flow_add_edge(p,N,1); } for(i=0;i<E;i++) { int a,b; scanf("%d%d",&a,&b); flow_add_edge(a,b,1); flow_add_edge(b,a,1); } /* Don't ret Takahashikun travel from 0 to n! */ /* minimum-cut ant book p.191 */ printf("%d\n",get_max_flow(0,N)); return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - 浮気予防 |
User | mikecat |
Language | C (GCC 4.6.4) |
Score | 99 |
Code Size | 1727 Byte |
Status | WA |
Exec Time | 28 ms |
Memory | 932 KB |
Compile Error
./Main.c: In function ‘main’: ./Main.c:66:7: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result] ./Main.c:70:8: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result] ./Main.c:75:8: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
Judge Result
Set Name | part | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 99 / 99 | 0 / 1 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
part | test_01_AB.txt, test_02_AB.txt, test_03_AB.txt, test_04_AB.txt, test_05_AB.txt, test_06_AB.txt, test_07_AB.txt, test_08_AB.txt, test_09_AB.txt, test_10_AB.txt, test_11_AB.txt, test_12_AB.txt, test_13_AB.txt, test_14_AB.txt, test_15_AB.txt, test_16_AB.txt, test_17_AB.txt, test_18_AB.txt, test_19_AB.txt, test_20_AB.txt, test_21_AB.txt, test_22_AB.txt, test_23_AB.txt, test_24_AB.txt, test_25_AB.txt, test_41_AB.txt, test_47_AB.txt |
All | sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, sample_05.txt, test_01_AB.txt, test_02_AB.txt, test_03_AB.txt, test_04_AB.txt, test_05_AB.txt, test_06_AB.txt, test_07_AB.txt, test_08_AB.txt, test_09_AB.txt, test_10_AB.txt, test_11_AB.txt, test_12_AB.txt, test_13_AB.txt, test_14_AB.txt, test_15_AB.txt, test_16_AB.txt, test_17_AB.txt, test_18_AB.txt, test_19_AB.txt, test_20_AB.txt, test_21_AB.txt, test_22_AB.txt, test_23_AB.txt, test_24_AB.txt, test_25_AB.txt, test_26_A.txt, test_27_A.txt, test_28_A.txt, test_29_A.txt, test_30_A.txt, test_31_A.txt, test_32_A.txt, test_33_A.txt, test_34_A.txt, test_35_A.txt, test_36_A.txt, test_37_A.txt, test_38_A.txt, test_39_A.txt, test_40_A.txt, test_41_AB.txt, test_42_A.txt, test_43_A.txt, test_44_A.txt, test_45_A.txt, test_46_A.txt, test_47_AB.txt, test_48_A.txt, test_49_A.txt, test_50_A.txt, test_51_A.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
sample_01.txt | AC | 20 ms | 796 KB |
sample_02.txt | AC | 21 ms | 796 KB |
sample_03.txt | AC | 28 ms | 864 KB |
sample_04.txt | AC | 21 ms | 804 KB |
sample_05.txt | AC | 21 ms | 796 KB |
test_01_AB.txt | AC | 19 ms | 804 KB |
test_02_AB.txt | AC | 20 ms | 688 KB |
test_03_AB.txt | AC | 20 ms | 796 KB |
test_04_AB.txt | AC | 20 ms | 796 KB |
test_05_AB.txt | AC | 19 ms | 924 KB |
test_06_AB.txt | AC | 21 ms | 804 KB |
test_07_AB.txt | AC | 20 ms | 804 KB |
test_08_AB.txt | AC | 20 ms | 680 KB |
test_09_AB.txt | AC | 20 ms | 808 KB |
test_10_AB.txt | AC | 20 ms | 796 KB |
test_11_AB.txt | AC | 19 ms | 668 KB |
test_12_AB.txt | AC | 20 ms | 800 KB |
test_13_AB.txt | AC | 19 ms | 792 KB |
test_14_AB.txt | AC | 21 ms | 788 KB |
test_15_AB.txt | AC | 19 ms | 804 KB |
test_16_AB.txt | AC | 22 ms | 796 KB |
test_17_AB.txt | AC | 20 ms | 860 KB |
test_18_AB.txt | AC | 19 ms | 672 KB |
test_19_AB.txt | AC | 19 ms | 932 KB |
test_20_AB.txt | AC | 21 ms | 700 KB |
test_21_AB.txt | AC | 22 ms | 764 KB |
test_22_AB.txt | AC | 18 ms | 796 KB |
test_23_AB.txt | AC | 20 ms | 800 KB |
test_24_AB.txt | AC | 20 ms | 736 KB |
test_25_AB.txt | AC | 20 ms | 800 KB |
test_26_A.txt | WA | 24 ms | 924 KB |
test_27_A.txt | WA | 22 ms | 932 KB |
test_28_A.txt | WA | 22 ms | 844 KB |
test_29_A.txt | WA | 21 ms | 800 KB |
test_30_A.txt | WA | 21 ms | 864 KB |
test_31_A.txt | WA | 22 ms | 868 KB |
test_32_A.txt | AC | 22 ms | 796 KB |
test_33_A.txt | WA | 20 ms | 804 KB |
test_34_A.txt | AC | 22 ms | 800 KB |
test_35_A.txt | AC | 21 ms | 800 KB |
test_36_A.txt | AC | 23 ms | 800 KB |
test_37_A.txt | AC | 20 ms | 804 KB |
test_38_A.txt | AC | 20 ms | 800 KB |
test_39_A.txt | AC | 19 ms | 672 KB |
test_40_A.txt | AC | 20 ms | 800 KB |
test_41_AB.txt | AC | 18 ms | 700 KB |
test_42_A.txt | WA | 21 ms | 928 KB |
test_43_A.txt | AC | 19 ms | 672 KB |
test_44_A.txt | AC | 20 ms | 932 KB |
test_45_A.txt | AC | 21 ms | 800 KB |
test_46_A.txt | AC | 21 ms | 796 KB |
test_47_AB.txt | AC | 20 ms | 700 KB |
test_48_A.txt | AC | 20 ms | 804 KB |
test_49_A.txt | AC | 19 ms | 668 KB |
test_50_A.txt | AC | 20 ms | 672 KB |
test_51_A.txt | AC | 20 ms | 736 KB |