60792023-10-29 16:37:53horvathabelBürokrácia (40)cpp17Wrong answer 13/40400ms7044 KiB
#include <bits/stdc++.h>
using namespace std;
vector<int> t;
vector<pair<char,int>> tv={{'0',0}};
void vissza(int j, int l){
    if (l%2==1){
        if (t[j]==1){
            t[j]=-1;
            if(tv[j].first=='V'){
                vissza(tv[j].second,l+1);
            }
        }
    }
    else{
        if (t[j]==-1){
            t[j]=1;
            if (tv[j].first=='V'){
                vissza(tv[j].second,l+1);
            }
        }
    }

}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    t.resize(n+1, 1);
    for (int i=1; i<=n;i++){
        char a;
        cin>>a;
        if (a=='V'){
            int x;
            cin>>x;
            tv.push_back({a,x});
            vissza(x,1);
        }
        else tv.push_back({a,0});
    }
    int ans=0;
    for (int i=1; i<=n;i++) if (t[i]==1) ans++;
    cout<<ans<<endl;
    for (int i=1; i<=n;i++) if (t[i]==1) cout<<i<<" ";

}
SubtaskSumTestVerdictTimeMemory
base13/40
1Accepted0/03ms1828 KiB
2Accepted1/13ms2020 KiB
3Wrong answer0/13ms2256 KiB
4Wrong answer0/13ms2600 KiB
5Accepted1/114ms5600 KiB
6Time limit exceeded0/1368ms2840 KiB
7Accepted1/124ms5772 KiB
8Wrong answer0/226ms5772 KiB
9Wrong answer0/226ms6036 KiB
10Wrong answer0/228ms5988 KiB
11Wrong answer0/227ms6244 KiB
12Accepted2/216ms6512 KiB
13Wrong answer0/216ms6728 KiB
14Wrong answer0/226ms6812 KiB
15Wrong answer0/221ms6764 KiB
16Accepted2/216ms6908 KiB
17Wrong answer0/216ms6752 KiB
18Wrong answer0/216ms6740 KiB
19Accepted2/214ms6724 KiB
20Accepted2/214ms6728 KiB
21Accepted2/214ms6984 KiB
22Time limit exceeded0/2400ms4884 KiB
23Wrong answer0/4101ms7044 KiB