37882023-03-02 22:09:28SleepyOverlordBürokrácia (40)cpp17Hibás válasz 16/40156ms4688 KiB
#include <vector>
#include <string> 
#include <set> 
#include <map> 
#include <unordered_set>
#include <unordered_map>
#include <queue> 
#include <bitset> 
#include <stack>
#include <list>

#include <numeric> 
#include <algorithm> 
#include <random>
#include <chrono>

#include <cstdio>
#include <fstream>
#include <iostream> 
#include <sstream> 
#include <iomanip>
#include <climits>

#include <cctype>
#include <cmath> 
#include <ctime>
#include <cassert>

using namespace std;

#define ULL unsigned long long
#define LL long long
#define PII pair <int, int>
#define VB vector <bool>
#define VI vector <int>
#define VLL vector <LL>
#define VD vector <double>
#define VS vector <string>
#define VPII vector <pair <int, int> >
#define VVI vector < VI >
#define VVB vector < VB >
#define SI set < int >
#define USI unordered_set <int>
#define MII map <int, int>
#define UMII unordered_map <int, int>
#define MS multiset
#define US unordered_set
#define UM unordered_map
#define UMS unordered_multiset
#define UMM unordered_multimap

#define FORN(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)

#define SZ size()
#define BG begin() 
#define EN end() 
#define CL clear()
#define X first
#define Y second
#define RS resize
#define PB push_back
#define MP make_pair
#define ALL(x) x.begin(), x.end()
#define INS insert
#define ER erase
#define CNT count

#define IN_FILE "a.in"
#define OUT_FILE "a.out"

template <typename T>
void PR(T var1)
{
	cout << var1 <<endl;
}
template <typename T, typename... Types>
void PR(T var1, Types... var2)
{
	cout << var1;
	PR(var2...);
}

int n;
VI a;
VB was, active;

int main()
{
	//freopen(IN_FILE, "r", stdin);
	//freopen(OUT_FILE, "w", stdout);

	cin >> n;
	a.RS(n + 1);
	FOR(i, 1, n)
	{
		string s;
		cin >> s;
		if (s == "V")
		{
			int x;
			cin >> x;
			a[i] = x;
		}
	}
	was.RS(n + 1);
	active.RS(n + 1, true);
	int nActive = n;
	FORD(i, n, 1)
		if (a[i] && !was[i])
		{
			int j = i, step = 1;
			while (j)
			{
				was[j] = true;
				if (step % 2 == 0) 
				{
					if (active[j]) --nActive;
					active[j] = false;
				}
				j = a[j];
				++step;
			}
		}

	PR(nActive);
	FOR(i, 1, n)
		if (active[i]) cout << i << " ";

	return 0;
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
base16/40
1Elfogadva0/03ms1808 KiB
2Elfogadva1/13ms2056 KiB
3Hibás válasz0/12ms2116 KiB
4Hibás válasz0/13ms2332 KiB
5Elfogadva1/128ms3368 KiB
6Elfogadva1/154ms3408 KiB
7Elfogadva1/152ms3384 KiB
8Hibás válasz0/252ms3636 KiB
9Hibás válasz0/254ms3776 KiB
10Hibás válasz0/254ms3736 KiB
11Hibás válasz0/254ms3992 KiB
12Elfogadva2/232ms4312 KiB
13Hibás válasz0/232ms4624 KiB
14Hibás válasz0/252ms4580 KiB
15Hibás válasz0/245ms4440 KiB
16Elfogadva2/232ms4368 KiB
17Hibás válasz0/232ms4688 KiB
18Hibás válasz0/232ms4584 KiB
19Elfogadva2/229ms4640 KiB
20Elfogadva2/228ms4580 KiB
21Elfogadva2/228ms4584 KiB
22Elfogadva2/254ms4580 KiB
23Hibás válasz0/4156ms4580 KiB