81532024-01-12 14:48:58ZsBalazsTitkos sorozatcpp17Wrong answer 0/406ms10428 KiB
#include <bits/stdc++.h>
using namespace std;

vector<vector<int>> graph;
vector<int> megoldas;
vector<int> mutat;
vector<bool> volt;

void bejar(int current) {
    if (volt[current]) return;
    
    volt[current] = true;
    
    for (int szom : graph[current]) {
        if (megoldas[szom] < megoldas[current]+1) {
            megoldas[szom] = megoldas[current]+1;
        }
        mutat[szom]--;
    }
}

int main() {
    int n;
    cin >> n;
    
    graph.resize(n);
    megoldas.assign(n, 0);
    mutat.assign(n, 0);
    volt.assign(n, false);
    
    cout << 1 << endl;
    return 0;
    
    for (int i = 0; n > i; i++) {
        int temp;
        cin >> temp;
        
        if (temp != -1) {
            temp--;
            
            mutat[temp]++;
            graph[i].push_back(temp);
            
            for (int j = i+1; temp > j; j++) {
                mutat[i]++;
                graph[j].push_back(i);
            }
        } else {
            for (int j = i+1; n > j; j++) {
                graph[j].push_back(i);
                mutat[i]++;
            }
        }
    }
    
    int counter = 0;
    while (counter < n) {
        for (int i = 0; n > i; i++) {
            if (mutat[i] == 0 && !volt[i]) {
                bejar(i);
                counter++;
            }
        }   
    }
    
    // megoldas, index
    vector<pair<int, int>> sor;
    
    for (int i = 0; n > i; i++) {
        sor.push_back({megoldas[i], i});
    }
    
    sort(sor.begin(), sor.end());
    
    vector<int> ans(n, 0);
    
    int next = 1;
    for (int i = 0; n > i; i++) {
        int index = sor[i].second;
        
        ans[index] = next;
        
        next++;
    }
    
    for (int a : ans) {
        cout << a << " ";
    }
    cout << endl;
    
	return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/40
1Wrong answer0/03ms1876 KiB
2Wrong answer0/04ms5156 KiB
3Wrong answer0/13ms2348 KiB
4Wrong answer0/13ms2516 KiB
5Wrong answer0/23ms2760 KiB
6Wrong answer0/13ms2884 KiB
7Wrong answer0/13ms3140 KiB
8Wrong answer0/23ms3220 KiB
9Wrong answer0/26ms9196 KiB
10Wrong answer0/24ms9380 KiB
11Wrong answer0/24ms9688 KiB
12Wrong answer0/24ms9636 KiB
13Wrong answer0/24ms9600 KiB
14Wrong answer0/24ms9612 KiB
15Wrong answer0/24ms9796 KiB
16Wrong answer0/34ms10020 KiB
17Wrong answer0/36ms10048 KiB
18Wrong answer0/34ms10028 KiB
19Wrong answer0/34ms10028 KiB
20Wrong answer0/34ms10296 KiB
21Wrong answer0/14ms10380 KiB
22Wrong answer0/14ms10412 KiB
23Wrong answer0/14ms10428 KiB