23432023-01-10 20:36:56nmarciBürokrácia (40)cpp11Wrong answer 16/40145ms6268 KiB
#include <bits/stdc++.h>

using namespace std;
using ll = long long int;
const ll inf = 1e9;

int main()
{
  int n;
  cin >> n;
  vector<int> v(n + 1);
  vector<bool> head(n + 1, true);
  for(int i = 1; i <= n; ++i){
    char c;
    cin >> c;
    if(c == 'V'){
      int j;
      cin >> j;
      head[j] = false;
      v[i] = j;
    }
  }
  vector<bool> active(n + 1, true);
  for(int i = 1; i <= n; ++i){
    if(head[i]){
      int ptr = v[i], ctr = 0;
      while(ptr != 0){
        active[ptr] = ctr % 2;
        ++ctr;
        ptr = v[ptr];
      }
    }
  }
  vector<int> sol;
  for(int i = 1; i <= n; ++i){
    if(active[i]) sol.push_back(i);
  }
  cout << sol.size() << endl;
  for(auto i : sol)
    cout << i << " ";
  return 0;
}
SubtaskSumTestVerdictTimeMemory
base16/40
1Accepted0/03ms1720 KiB
2Accepted1/12ms1848 KiB
3Wrong answer0/12ms2052 KiB
4Wrong answer0/13ms2264 KiB
5Accepted1/123ms4532 KiB
6Accepted1/148ms3960 KiB
7Accepted1/146ms4236 KiB
8Wrong answer0/250ms4296 KiB
9Wrong answer0/250ms4500 KiB
10Wrong answer0/250ms4704 KiB
11Wrong answer0/250ms5288 KiB
12Accepted2/225ms5348 KiB
13Wrong answer0/225ms5540 KiB
14Wrong answer0/246ms5784 KiB
15Wrong answer0/237ms6016 KiB
16Accepted2/225ms6040 KiB
17Wrong answer0/225ms5948 KiB
18Wrong answer0/225ms6008 KiB
19Accepted2/223ms6016 KiB
20Accepted2/223ms6136 KiB
21Accepted2/223ms6268 KiB
22Accepted2/248ms5760 KiB
23Wrong answer0/4145ms5764 KiB