heres my code
Code: Select all
Moderator: Board moderators
Code: Select all
Code: Select all
1
3 2
1 1
1 0
0 1
Code: Select all
Yes
Code: Select all
void call(int n,int m){
int count=0,fc=0;
for(int j=0;j<m;j++){
count=0;
for(int i=0;i<n;i++){
if(arr[i][j]=='1')count++;
}
if(count==2)
fc++;
}
if(fc==m)
cout<<"Yes"<<endl;
else cout<<"No"<<endl;
return;
}
can you say more detail?rij wrote:thanks got ac after a number of tries.
Code: Select all
void prepare()
{
scanf("%d%d",&n,&m);
for (int i=1;i<=n;i++)
for (int j=1;j<=n;j++)
flag[i][j]=false;
for (int i=1;i<=n;i++)
for (int j=1;j<=m;j++)
scanf("%d",&map[i][j]);
}
bool work()
{
for (int i=1;i<=m;i++)
{
int u=-1,v=-1;
for (int j=1;j<=n;j++)
if (map[j][i])
{
if (u==-1) u=j;else
if (v!=-1) return false;else v=j;
}
if (u*v<0) return false;
if (flag[u][v]) return false;
flag[u][v]=flag[v][u]=true;
}
return true;
}
Code: Select all
if (u*v<0) return false;
Code: Select all
if (u==-1||v==-1) return false;
Code: Select all
3
3 3
1 1 0
1 1 1
1 0 0
2 2
1 1
1 1
3 3
1 0 0
1 1 1
0 1 1
Code: Select all
No
No
No
Code: Select all
1
4 3
1 1 1
1 0 0
0 1 0
0 0 0