61022023-10-29 21:03:01horvathabelBürokrácia (40)cpp17Accepted 40/4024ms8260 KiB
#include <bits/stdc++.h>
using namespace std;
vector<pair<char,int>> tv={{'0',0}};
vector<int> t;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    t.resize(n+1,0);
    for (int i=1; i<=n;i++){
        char a;
        cin>>a;
        if (a=='V'){
            int x;
            cin>>x;
            tv.push_back({a,x});
        }
        else tv.push_back({a,0});
    }
    int ans=0;
    vector<int> v;
    for (int i=n;i>0;i--){

        if (t[i]==0){
            ans++;
            v.push_back(i);
            if (tv[i].first=='V'){
                if (t[tv[i].second]==0) t[tv[i].second]=1;
            }
        }

    }
    cout<<ans<<endl;
    reverse(v.begin(), v.end());
    for (int x: v) cout<<x<<" ";
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1828 KiB
2Accepted1/13ms2052 KiB
3Accepted1/13ms2264 KiB
4Accepted1/13ms2596 KiB
5Accepted1/117ms6676 KiB
6Accepted1/121ms6060 KiB
7Accepted1/120ms6080 KiB
8Accepted2/221ms6084 KiB
9Accepted2/223ms6300 KiB
10Accepted2/223ms6300 KiB
11Accepted2/223ms6320 KiB
12Accepted2/217ms7172 KiB
13Accepted2/217ms7380 KiB
14Accepted2/223ms6756 KiB
15Accepted2/220ms7312 KiB
16Accepted2/217ms7384 KiB
17Accepted2/217ms7648 KiB
18Accepted2/217ms7908 KiB
19Accepted2/216ms7936 KiB
20Accepted2/216ms8260 KiB
21Accepted2/216ms8076 KiB
22Accepted2/221ms7664 KiB
23Accepted4/424ms7696 KiB