60952023-10-29 18:17:39hackemonBürokrácia (40)cpp17Wrong answer 8/4034ms16380 KiB
#include <bits/stdc++.h>
using namespace std;
//using namespace std::chrono;

#define pii pair<int,int>
#define pb push_back
#define vi vector<int>
#define vb vector<bool>
#define vl vector<ll>
#define vvi vector<vi>
#define vvb vector<vb>
#define vvl vector<vl>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define fScan {ios_base::sync_with_stdio(false); cin.tie(NULL);}
#define rep(i, a, b) for(int i = a; i < (b); i++)
#define REP(i, n) for(int i = 0;i <(n); i++)
using ll = long long;
using ld = long double;
ll mod = 1000000007;

const char ny =  '\n';

bool prime(ll a) {
    if (a==1) return 0;
    for (int i=2;i*i<=a;++i)
    {
        if (a%i==0) return 0;
    }
    return 1;
}

ll gcd(ll a,ll b) {
    if (b==0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b)
{
    return a/gcd(a,b)*b;
}

ll min(int a, ll b) {
    if(a< b) return a;
    else return b;
}

void dfs(int ki) {

}
int n = 100001;
vector<int> be(n+1);
vector<vector<int>> ki(n+1);
vector<bool> jo(n+1, 1);



void solve() { 
        cin >> n;
        for(int i = 1;i <= n;i++ ) {
            char v;
            cin >> v;
            
            if(v == 'V') {
                int val;
                cin >> val;
               be[val]++;
               ki[i].push_back(val);
            }
        }

        for(int i = 1;i<=n;i++ ) {
            if(be[i] == 0) { 
                if(ki[i].size() > 0) {
                    jo[ki[i][0]] = 0;
                }
            }
        }
    
        int total = 0;
        for(int i = 1;i< n+1;i++ ) {
            total+= jo[i];
        }

        cout << total << '\n';
        for(int i = 1;i < n+1;i++ ) {
            if(jo[i] == 1)
            cout << i << ' ';
        }
    }


int main()
{
    fScan

    int t = 1;
    //comment out if necessary
    //cin>> t;


    //auto start = high_resolution_clock::now();
    while(t-- ) {
        solve();
    }
    //auto end = high_resolution_clock::now();
    //auto dur = duration_cast<milliseconds>(end-start);
    //cout<< "runtime: " << dur.count() << " milliseconds" << '\n';
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base8/40
1Accepted0/04ms7260 KiB
2Accepted1/14ms7528 KiB
3Wrong answer0/14ms7352 KiB
4Wrong answer0/14ms7636 KiB
5Accepted1/116ms7920 KiB
6Wrong answer0/134ms14824 KiB
7Wrong answer0/132ms14300 KiB
8Wrong answer0/232ms14496 KiB
9Wrong answer0/230ms14504 KiB
10Wrong answer0/230ms14504 KiB
11Wrong answer0/230ms14840 KiB
12Wrong answer0/217ms10000 KiB
13Wrong answer0/217ms9908 KiB
14Wrong answer0/229ms14256 KiB
15Wrong answer0/226ms12796 KiB
16Wrong answer0/217ms10304 KiB
17Wrong answer0/217ms10476 KiB
18Wrong answer0/217ms10688 KiB
19Accepted2/216ms9976 KiB
20Accepted2/214ms10260 KiB
21Accepted2/216ms10364 KiB
22Wrong answer0/234ms16380 KiB
23Wrong answer0/434ms16252 KiB