glass.pas added
[srcbox.git] / usaco / concom.cpp~
blobdef7a49d16a9ab774ed6feaa1ae0185c793f904b
1 /*
2 ID: xiaozqh1
3 PROG: concom
4 LANG: C++
5 */
6 #include <iostream>
7 #include <fstream>
8 using namespace std;
9 int a[100][100];
10 bool test[100][100][100];
11 int main() {
12   ifstream fin ("concom.in");
13   ofstream fout ("concom.out");
14   int i,j,k,n,x,y,z;
15   fin>>n;
16   for (i=0;i<n;i++) { fin>>x>>y>>z; a[x-1][y-1]=z; }
17   for (z=0;z<100;z++) {
18   for (k=0;k<100;k++) {
19     for (i=0;i<100;i++) {
20       for (j=0;j<100;j++) {
21          if (a[i][k]>50 && i!=j && test[i][j][k]==false) { a[i][j]+=a[k][j]; test[i][j][k]=true; }
22        }
23      }
24    }
25   }
26    for (i=0;i<100;i++) {
27      for (j=0;j<100;j++) {
28         if (a[i][j]>50 && i!=j) { fout<<i+1<<' '<<j+1<<endl; }
29       }
30     }
31     return 0;
32
33