70542023-12-29 07:37:16MagyarKendeSZLGLegtöbb unoka (80 pont)cpp17Accepted 80/806ms5164 KiB
#include <bits/stdc++.h>

#define speed cin.tie(0); ios::sync_with_stdio(0)

using namespace std;
using u16 = unsigned short;

int main() {
    speed;

    u16 N, M;
    cin >> N >> M;

    vector<vector<u16>> g(N + 1);
    while (M--) {
        u16 U, V;
        cin >> U >> V;
        g[U].push_back(V);
    }

    int max_n = 0, max_v = 0;

    for (int s = 1; s <= N; s++) {
        int curr = 0;
        for (int child : g[s]) {
            curr += g[child].size();
        }
        if (max_v < curr) {
            max_v = curr;
            max_n = s;
        }
    }

    if (max_v) {
        cout << max_n << ' ' << max_v;
    } else {
        cout << -1;
    }
}
SubtaskSumTestVerdictTimeMemory
base80/80
1Accepted0/03ms1832 KiB
2Accepted0/04ms2708 KiB
3Accepted4/43ms2108 KiB
4Accepted4/43ms2320 KiB
5Accepted4/46ms3356 KiB
6Accepted4/46ms3472 KiB
7Accepted4/43ms2864 KiB
8Accepted4/43ms3080 KiB
9Accepted4/44ms3620 KiB
10Accepted4/46ms4268 KiB
11Accepted4/44ms4164 KiB
12Accepted4/44ms3964 KiB
13Accepted4/46ms4544 KiB
14Accepted4/46ms4776 KiB
15Accepted4/44ms4532 KiB
16Accepted4/44ms4468 KiB
17Accepted4/46ms4672 KiB
18Accepted4/46ms4716 KiB
19Accepted2/23ms4320 KiB
20Accepted2/23ms4280 KiB
21Accepted3/33ms4416 KiB
22Accepted3/33ms4712 KiB
23Accepted3/36ms5164 KiB
24Accepted3/34ms5160 KiB