30512023-02-08 23:39:17xxxLegtöbb unoka (80 pont)cpp14Accepted 80/809ms5532 KiB
#include <bits/stdc++.h>
#include <vector>
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a[n+1];
    int x, y;
    for (int i = 0; i < m; i++) {
        cin >> x >> y;
        a[x].push_back(y);
    }

    int unokak, legtobbunoka = 0, unokai;
    for (int i = 1; i <= n; i++) {
        unokak = 0;
        for (int j = 0; j < a[i].size(); j++) {
          	unokak += a[a[i][j]].size();
       }
        if (unokak > legtobbunoka) {
            legtobbunoka = unokak;
            unokai = i;
        }
    }
	
	if (legtobbunoka == 0) {cout << -1 << endl; return 0;}


    cout << unokai << " " << legtobbunoka << endl;

    return 0;

}
SubtaskSumTestVerdictTimeMemory
base80/80
1Accepted0/03ms1720 KiB
2Accepted0/06ms2628 KiB
3Accepted4/43ms2192 KiB
4Accepted4/43ms2392 KiB
5Accepted4/49ms3360 KiB
6Accepted4/49ms3300 KiB
7Accepted4/43ms2656 KiB
8Accepted4/43ms2892 KiB
9Accepted4/46ms3608 KiB
10Accepted4/49ms3988 KiB
11Accepted4/49ms4216 KiB
12Accepted4/46ms4076 KiB
13Accepted4/49ms4660 KiB
14Accepted4/49ms4764 KiB
15Accepted4/49ms4832 KiB
16Accepted4/49ms4868 KiB
17Accepted4/48ms5176 KiB
18Accepted4/49ms4956 KiB
19Accepted2/23ms4480 KiB
20Accepted2/23ms4736 KiB
21Accepted3/33ms4692 KiB
22Accepted3/33ms4848 KiB
23Accepted3/39ms5532 KiB
24Accepted3/38ms5448 KiB