-
Notifications
You must be signed in to change notification settings - Fork 0
/
factory.cpp
45 lines (40 loc) · 1.26 KB
/
factory.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//Milk Factory
//By: Max Yang
//Time: 45 minutes
#include <stdio.h>
#include <cstdlib>
int main(){
FILE * In = fopen("factory.in", "r");
int N;
fscanf(In, "%d", &N);
int A[N], B[N];
for(int i=0; i<=N; i++){
fscanf(In, "%d %d", &A[i], &B[i]);
}
fclose(In);
for(int i_lines = 1; i_lines <=N-1; i_lines++){
int lines = i_lines;
for(int i_stations=1; i_stations<=N; i_stations++){
int stations = i_stations;
int count;
count++;
if(B[lines] == stations){
break;
}
}
}
for(int i_afterlines=1+count; i_afterlines<=N-1; i_afterlines++)
int afterlines=i_afterlines;
if(B[afterlines] ==stations){
int secound_count;
second_count++;
}
}
if(second_count==N-1){
printf("station: %d", secound_count);
}else{
second_count = -1;
}
FILE * Out = fopen("factory.out", "w");
fprintf(Out, "%d\n", second_count);
fclose(Out);