22342023-01-04 15:55:001478Bürokrácia (40)cpp11Accepted 40/4048ms5840 KiB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> p32;
typedef pair<ll, ll> p64;
typedef pair<double, double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int>> vv32;
typedef vector<vector<ll>> vv64;
typedef vector<vector<p64>> vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
double eps = 1e-12;
#define forn(i, e) for (ll i = 0; i < e; i++)
#define forsn(i, s, e) for (ll i = s; i < e; i++)
#define rforn(i, s) for (ll i = s; i >= 0; i--)
#define rforsn(i, s, e) for (ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout << #x << " = " << x << ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 2e18
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())

int main()
{
    //ifstream cin("be.txt");
    int n;
    cin >> n;
    vector<int> a(n + 1);
    for (int i = 1; i <= n; i++)
    {
        char c;
        cin >> c;
        if (c == 'V')
        {
            cin >> a[i];
        }
    }

    vector<int> active(n + 1, 1);
    int ans = 0;

    for (int i = n; i >= 1; i--)
    {
        if (active[i])
        {
            ans++;
            active[a[i]] = 0;
        }
    }

    cout << ans << '\n';
    for (int i = 1; i <= n; i++)
    {
        if(active[i]){
            cout << i << " ";      
        }
    }

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1812 KiB
2Accepted1/12ms1908 KiB
3Accepted1/12ms2104 KiB
4Accepted1/13ms2464 KiB
5Accepted1/121ms4152 KiB
6Accepted1/148ms4204 KiB
7Accepted1/146ms4440 KiB
8Accepted2/246ms4620 KiB
9Accepted2/246ms4684 KiB
10Accepted2/246ms4812 KiB
11Accepted2/246ms4896 KiB
12Accepted2/224ms4972 KiB
13Accepted2/224ms4968 KiB
14Accepted2/243ms5224 KiB
15Accepted2/235ms5452 KiB
16Accepted2/224ms5388 KiB
17Accepted2/224ms5536 KiB
18Accepted2/224ms5568 KiB
19Accepted2/221ms5764 KiB
20Accepted2/221ms5840 KiB
21Accepted2/221ms5732 KiB
22Accepted2/248ms5728 KiB
23Accepted4/448ms5728 KiB