eolymp
bolt
Try our new interface for solving problems
Məsələlər

Çıxışlar və grişlər

dərc olunub 16.01.24 21:51:40
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int graph[n+1][n+1];
    int a[n+1], b[n+1];
    memset(a, 0, sizeof(a));
    memset(b, 0, sizeof(b));
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            cin>>graph[i][j];
            if(graph[i][j] == 1){
                a[j]++;
                b[i]++;
            }
        }
    }
    int sor = count(a+1, a+n+1, 0);
    cout<<sor<<" ";
    for(int i = 1; i <= n; i++){
        if(a[i] == 0){
            cout<<i<<" ";
        }
    }
    cout<<endl;
    int sin = count(b+1, b+n+1, 0);
    cout<<sin<<" ";
    for(int i = 1; i <= n; i++){
        if(b[i] == 0){
            cout<<i<<" ";
        }
    }
    return 0;
}

C++ solution using graph