heres my code
- Code: Select all
Moderator: Board moderators
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;
}
rij wrote:thanks got ac after a number of tries.
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;
}
if (u*v<0) return false;
if (u==-1||v==-1) return false;
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 1No
No
No1
4 3
1 1 1
1 0 0
0 1 0
0 0 0Users browsing this forum: No registered users and 1 guest