Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- include <fstream>
- using namespace std;
- int main(){
- ifstream cin("input.txt");
- ofstream cout("output.txt");
- int _new[50],_old[50],a[100][100],chek[100];
- int n,count = 0;;
- cin >> n;
- for (int i=0; i<10;i++)
- chek[i] = 0;
- _old[0] = 1;
- _old[1] = 1;
- for (int i=1; i<=n;i++){
- for (int j = 1; j<=n; j++)
- cin >> a[i][j];
- }
- chek[1] = 1;
- while (1){
- for (int i=1; i <= _old[0]; i++){
- for (int j=_old[i]; j <= n; j++){
- // cout << "!" << a[_old[i]][j] << endl;
- if ((a[_old[i]][j] == 1) && (chek[j] == 0)){
- //cout << "!!!!!!!!!!!"<< endl;
- chek[j] = 1;
- _new[0]++;
- _new[_new[0]] = j;
- }
- }
- cout << "!!!" << _new[0] << endl;
- for (int t = 0; t <= _new[0];t++)
- cout << _new[t] << " ";
- cout << endl;
- }
- for (int t = 0; t <= _new[0];t++)
- _old[t] = _new[t];
- _new[0] = 0;
- count++;
- if (chek[8] == 1) break;
- }
- cout << count;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement