# (cant able to understand whats wrong)Fill The Matrix Problem Code: FILLMTR (https://www.codechef.com/problems/FILLMTR)

this is my code, can you please let me know where is the issue in my code.

``````#include <iostream>
#define MAXX 1000001

using namespace std;

struct node {
int id, rank;
int color;
node* parant;
};

node arr[MAXX];

node* find(node* x) {
if (x->parant == x)
{
return x;
}
x->parant = find(x->parant);
return x->parant;
}
int inpt[MAXX][2];
int N, Q, inptpoi;
int main() {
int test;
cin >> test;
int ans;
for (int t = 0; t < test; t++)
{
inptpoi = -1;
ans = 1;
cin >> N >> Q;
for (int i = 0; i <= N; i++)
{

arr[i].id = i;
arr[i].parant = &arr[i];
arr[i].color = -1;
arr[i].rank = 1;
}
for (int i = 0; i < Q; i++)
{
int x, y, val;
cin >> x >> y >> val;
if (val == 1)
{
inpt[++inptpoi][0] = x;
inpt[inptpoi][1] = y;
continue;
}
node *tempx = find(&arr[x]);
node *tempy = find(&arr[y]);

if (tempx != tempy)
{
if (tempx->rank > tempy->rank)
{
tempy->parant = tempx;
tempx->rank += tempy->rank;
}
else {
tempx->parant = tempy;
tempy->rank += tempx->rank;
}
}

}

while (inptpoi >= 0)
{
int x, y;
x = inpt[inptpoi][0];
y = inpt[inptpoi--][1];
node *tempx = find(&arr[x]);
node *tempy = find(&arr[y]);
if (tempx == tempy)
{
ans = 0;
break;
}
else {
if (tempx->color == -1)
{
tempx->color = tempy->color != 2 ? 2 : 1;
tempy->color = tempx->color == 1 ? 2 : 1;

}
else {
if (tempx->color == tempy->color)
{
ans = 0;
break;
}
tempy->color = tempx->color == 1 ? 2 : 1;
}
}
}

ans == 1 ? (cout << "yes" << endl) : (cout << "no" << endl);
}

return 0;
}``````