eolymp
bolt
Try our new interface for solving problems
Problems

Полустепени вершин по спискам ребер

published at 1/18/24, 7:50:13 pm
#include <bits/stdc++.h> 
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, m, x, y, res=0, res1=0;
    cin>>n>>m;
    int g[n+1][n+1];
    memset(g, 0, sizeof(g));
    while(m--){
        cin>>x>>y;
        g[x][y] = 1;
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            if(g[i][j] == 1){
                res++;
            }
            if(g[j][i] == 1){
                res1++;
            }
        }
        cout<<res1<<" "<<res<<endl;
        res1=0;
        res=0;
    }
    return 0;
}

C++ solution using graph