Submission #66939193


Source Code Expand

#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>

using namespace std;

const int MAXN = 200000;
const int MAXQ = 200000;
const int MAXLEN = 1000000;

struct Node
{
	int p;
	string s;
};

int n, q;
Node v[MAXQ+2];
int ans[MAXN+2];

void printAns(int node)
{
	if (!node) return;
	printAns(v[node].p);
	cout << v[node].s;
}

void solveTestcase()
{
	cin >> n >> q;
	for (int i = 1; i <= q; i++) {
		int tip, pc;
		cin >> tip >> pc;
		if (tip == 1) {
			ans[pc] = ans[0];
		}
		else if (tip == 2) {
			cin >> v[i].s;
			v[i].p = ans[pc];
			ans[pc] = i;
		}
		else {
			ans[0] = ans[pc];
		}
	}
	printAns(ans[0]);
}

int main()
{
	cin.tie(0)->sync_with_stdio(0);
	int t;
	t = 1;
	while (t--) {
		solveTestcase();
	}
	return 0;
}

Submission Info

Submission Time
Task D - Conflict 2
User Andrei_ierdnA
Language C++ 17 (gcc 12.2)
Score 425
Code Size 832 Byte
Status AC
Exec Time 37 ms
Memory 14540 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 425 / 425
Status
AC × 3
AC × 49
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 02_random2_00.txt, 02_random2_01.txt, 02_random2_02.txt, 02_random2_03.txt, 02_random2_04.txt, 02_random2_05.txt, 02_random2_06.txt, 02_random2_07.txt, 02_random2_08.txt, 02_random2_09.txt, 02_random2_10.txt, 02_random2_11.txt, 02_random2_12.txt, 02_random2_13.txt, 02_random2_14.txt, 02_random2_15.txt, 03_random3_00.txt, 03_random3_01.txt, 03_random3_02.txt, 03_random3_03.txt, 04_random4_00.txt, 04_random4_01.txt, 05_random5_00.txt, 05_random5_01.txt, 06_handmade_00.txt, 06_handmade_01.txt, 06_handmade_02.txt, 06_handmade_03.txt, 06_handmade_04.txt, 06_handmade_05.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 4 ms 11380 KiB
00_sample_01.txt AC 5 ms 11216 KiB
00_sample_02.txt AC 5 ms 11216 KiB
01_random_00.txt AC 7 ms 12516 KiB
01_random_01.txt AC 21 ms 11616 KiB
01_random_02.txt AC 21 ms 12116 KiB
01_random_03.txt AC 6 ms 12400 KiB
01_random_04.txt AC 20 ms 12632 KiB
01_random_05.txt AC 9 ms 11892 KiB
01_random_06.txt AC 6 ms 12508 KiB
01_random_07.txt AC 8 ms 12128 KiB
01_random_08.txt AC 18 ms 11908 KiB
01_random_09.txt AC 22 ms 12012 KiB
01_random_10.txt AC 19 ms 12664 KiB
01_random_11.txt AC 9 ms 11472 KiB
01_random_12.txt AC 16 ms 13104 KiB
01_random_13.txt AC 16 ms 12204 KiB
01_random_14.txt AC 21 ms 11276 KiB
01_random_15.txt AC 16 ms 11404 KiB
02_random2_00.txt AC 26 ms 12152 KiB
02_random2_01.txt AC 26 ms 12100 KiB
02_random2_02.txt AC 26 ms 12100 KiB
02_random2_03.txt AC 27 ms 12160 KiB
02_random2_04.txt AC 37 ms 14008 KiB
02_random2_05.txt AC 35 ms 14060 KiB
02_random2_06.txt AC 33 ms 13364 KiB
02_random2_07.txt AC 25 ms 12160 KiB
02_random2_08.txt AC 36 ms 13536 KiB
02_random2_09.txt AC 36 ms 14224 KiB
02_random2_10.txt AC 32 ms 13648 KiB
02_random2_11.txt AC 24 ms 11956 KiB
02_random2_12.txt AC 35 ms 13672 KiB
02_random2_13.txt AC 32 ms 13464 KiB
02_random2_14.txt AC 33 ms 14540 KiB
02_random2_15.txt AC 20 ms 11992 KiB
03_random3_00.txt AC 29 ms 13528 KiB
03_random3_01.txt AC 29 ms 13580 KiB
03_random3_02.txt AC 29 ms 13500 KiB
03_random3_03.txt AC 23 ms 12740 KiB
04_random4_00.txt AC 29 ms 13536 KiB
04_random4_01.txt AC 28 ms 13388 KiB
05_random5_00.txt AC 33 ms 14240 KiB
05_random5_01.txt AC 35 ms 14152 KiB
06_handmade_00.txt AC 5 ms 11312 KiB
06_handmade_01.txt AC 7 ms 12036 KiB
06_handmade_02.txt AC 21 ms 11960 KiB
06_handmade_03.txt AC 29 ms 12156 KiB
06_handmade_04.txt AC 19 ms 11408 KiB
06_handmade_05.txt AC 25 ms 12492 KiB