Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdio.h>
- using namespace std;
- int main()
- {
- int T;
- int n, m;
- cin >> T;
- while(T--)
- {
- cin >> n >> m;
- int grp[n][m];
- int arr[m+1];
- for(int i=0; i<n; i++)
- {
- cout << "Enitialising arr[" << i+1 << "] : " ;
- arr[i] = 0;
- cout << arr[i] << endl;
- for(int j = 0; j<m; j++)
- {
- cout << "Enitialising grp[" << i << "]" << "[" << j <<"] : ";
- grp[i][j] = 0;
- cout << grp[i][j] << endl;
- //grp[j][i] = 0;
- }
- }
- for(int i=0; i<n; i++){
- for(int j=0; j<m; j++){
- cout << grp[i][j] << "\t";
- }
- cout << endl;
- }
- cout << endl;
- int a, b, i, flag=1;
- for(i=0; i<m; i++)
- {
- cin >> a >> b;
- grp[a-1][b-1] = 1;
- grp[b-1][a-1] = 1;
- cout << "Setting grp[" << a-1 << "]" << "[" << b-1 <<"] : ";
- cout << grp[a-1][b-1] << endl;
- cout << "Setting grp[" << b-1 << "]" << "[" << a-1 <<"] : ";
- cout << grp[b-1][a-1] << endl;
- arr[a-1]++;
- cout <<"arr[" << a-1<<"]: "<< arr[a-1] << endl;
- arr[b-1]++;
- cout <<"arr[" << b-1<<"]: "<< arr[b-1] << endl;
- }
- for(int i=0; i<n; i++){
- for(int j=0; j<m; j++){
- cout << grp[i][j] << "\t";
- }
- cout << endl;
- }
- cout << endl;
- for(int i=0; i<m; i++)
- {
- if(arr[i] == 1)
- {
- cout << "No" << endl;
- flag = 0;
- break;
- }
- }
- if(flag)
- {
- cout << "YES" << endl;
- }
- cout << T << "th loop" << " " << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement