60772023-10-29 16:35:21horvathabelBürokrácia (40)cpp17Wrong answer 0/40354ms16164 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()
{
    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});
    }
    for (int i=1; i<=n;i++) cout<<t[i]<<" ";

}
SubtaskSumTestVerdictTimeMemory
base0/40
1Wrong answer0/03ms1808 KiB
2Wrong answer0/13ms2056 KiB
3Wrong answer0/13ms2272 KiB
4Wrong answer0/13ms2456 KiB
5Wrong answer0/123ms5712 KiB
6Time limit exceeded0/1354ms3192 KiB
7Wrong answer0/156ms6868 KiB
8Wrong answer0/254ms7592 KiB
9Wrong answer0/254ms8572 KiB
10Wrong answer0/257ms9512 KiB
11Wrong answer0/254ms10456 KiB
12Wrong answer0/227ms11004 KiB
13Wrong answer0/226ms11092 KiB
14Wrong answer0/252ms11796 KiB
15Wrong answer0/241ms12300 KiB
16Wrong answer0/226ms12900 KiB
17Wrong answer0/226ms13052 KiB
18Wrong answer0/226ms13376 KiB
19Wrong answer0/223ms13824 KiB
20Wrong answer0/223ms14212 KiB
21Wrong answer0/223ms14372 KiB
22Time limit exceeded0/2347ms13248 KiB
23Wrong answer0/4133ms16164 KiB