1292021-01-17 11:51:39Valaki2Parti (75 pont)cpp14Wrong answer 0/75136ms30336 KiB
#include <bits/stdc++.h>
using namespace std;

int n, ksz;
vector<int> g[100001];
vector<int> g2[100001];
vector<bool> volt(100001/*, false*/);
//vector<bool> volt2(100001, false);
vector<int> top;
//vector<int> scc(100001);

void dfs(int x) {
    if(volt[x]) return;
    volt[x] = true;
    for(int i : g[x]) dfs(i);
    top.push_back(x);
}

/*void dfs2(int y) {
    if(volt2[y]) return;
    volt2[y] = true;
    for(int i : g2[y]) dfs2(i);
    scc[y] = ksz;
}*/

int main() {
    cin >> n;
    for(int i = 1; i <= n; ++i) {
        int a, b;
        cin >> a >> b;
        g[i].push_back(a);
        g[i].push_back(b);
        g2[a].push_back(i);
        g2[b].push_back(i);
    }
    for(int i = 1; i <= n; ++i) dfs(i);
    //reverse(top.begin(), top.end());
    /*for(int cs : top) {
        //cout << cs << " ";
        if(!volt2[cs]) {
            ++ksz;
            dfs2(cs);
        }
    }*/
    /*cout << "\n";
    cout << ksz << "\n";
    for(int i = 1; i <= n; ++i) {
        cout << i << ": " << scc[i] << "\n";
    }*/
    /*vector<bool> joscc(1+ksz, true);
    for(int i = 1; i <= n; ++i) {
        int db = 0;
        for(int j = 0; j < g2[i].size(); ++j) {
            if(scc[g2[i][j]] == scc[i]) {
                ++db;
            }
        }
        if(db != 2) {
            joscc[scc[i]] = false;
        }
    }
    vector<int> cnt(1+ksz, 0);
    for(int i = 1; i <= n; ++i) {
        ++cnt[scc[i]];
    }
    int maxscc = 0, maxcnt = 0;
    for(int i = 1; i <= ksz; ++i) {
        if((maxscc == 0 || maxcnt < cnt[i]) && joscc[i]) {
            maxscc = i;
            maxcnt = cnt[i];
        }
    }
    cout << maxcnt << "\n";
    for(int i = 1; i <= n; ++i) {
        if(scc[i] == maxscc) {
            cout << i << " ";
        }
    }
    cout << "\n";*/
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/75
1Accepted0/07ms11176 KiB
2Accepted0/074ms20040 KiB
3Wrong answer0/36ms11716 KiB
4Wrong answer0/36ms11720 KiB
5Wrong answer0/36ms11732 KiB
6Wrong answer0/36ms11736 KiB
7Wrong answer0/36ms11744 KiB
8Wrong answer0/46ms11896 KiB
9Wrong answer0/46ms11948 KiB
10Wrong answer0/48ms12136 KiB
11Wrong answer0/47ms11976 KiB
12Wrong answer0/47ms12196 KiB
13Wrong answer0/48ms12404 KiB
14Wrong answer0/49ms12504 KiB
15Wrong answer0/468ms20748 KiB
16Wrong answer0/485ms22920 KiB
17Wrong answer0/4101ms25836 KiB
18Wrong answer0/4127ms28284 KiB
19Wrong answer0/4128ms29564 KiB
20Wrong answer0/4136ms30336 KiB
21Wrong answer0/4134ms30320 KiB
22Wrong answer0/46ms13896 KiB