236522026-01-27 08:14:49PappMatyasBizonyításcpp17Wrong answer 0/501.1s21844 KiB
#include <iostream>
#include <vector>

using namespace std;

vector<vector<int>> v;
vector<vector<int>> s;

static bool Contained(int x, int y)
{
	int sz = v[x].size();
	for (int i = 0; i < sz; i++)
	{
		if (v[x][i] == y)
		{
			return true;
		}
	}
	return false;
}

static void AddVector(int x, int y)
{
	if (!Contained(x, y))
	{
		v[x].push_back(y);
		int sz = v[y].size();
		for (int i = 0; i < sz; i++)
		{
			v[x].push_back(v[y][i]);
		}

		sz = s[x].size();
		int csz = v[x].size();
		
		for (int i = 0; i < sz; i++)
		{
			int ind = s[x][i];
			if (!Contained(ind, y))
			{
				v[ind].push_back(y);
			}
			
			for (int j = 0; j < csz; j++)
			{
				if (!Contained(ind, v[x][i]))
				{
					v[ind].push_back(v[x][i]);
				}
			}
		}

		s[y].push_back(x);
		sz = s[x].size();
		for (int i = 0; i < sz; i++)
		{
			if (s[x][i] != y)
			{
				s[y].push_back(s[x][i]);
			}
		}


		for (int i = 0; i < v.size(); i++)
		{
			cout << i << " : ";
			for (int j = 0; j < v[i].size(); j++)
			{
				cout << v[i][j] << " ";
			}
			cout << endl;
		}

		for (int i = 0; i < s.size(); i++)
		{
			cout << i << " : ";
			for (int j = 0; j < s[i].size(); j++)
			{
				cout << s[i][j] << " ";
			}
			cout << endl;
		}

	}
}

int main()
{
	int n, q;
	cin >> n >> q;
	
	vector<string> ans;

	for (int i = 0; i < n; i++)
	{
		v.push_back(vector<int>{});
		s.push_back(vector<int>{});
	}

	for (int i = 0; i < q; i++)
	{
		int t, x, y;
		cin >> t >> x >> y;

		x--; y--;

		if (t == 2)
		{
			ans.push_back(Contained(x, y) ? "IGEN" : "NEM");
		}
		else
		{
			AddVector(x, y);
		}
	}

	for (int i = 0; i < v.size(); i++)
	{
		cout << i << " : ";
		for (int j = 0; j < v[i].size(); j++)
		{
			cout << v[i][j] << " ";
		}
		cout << endl;
	}

	for (int i = 0; i < s.size(); i++)
	{
		cout << i << " : ";
		for (int j = 0; j < s[i].size(); j++)
		{
			cout << s[i][j] << " ";
		}
		cout << endl;
	}

	for (string k : ans)
	{
		cout << k << "\n";
	}
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Wrong answer1ms500 KiB
2Time limit exceeded1.087s9268 KiB
subtask20/10
3Wrong answer344ms6196 KiB
4Time limit exceeded1.082s20308 KiB
5Time limit exceeded1.082s6976 KiB
6Time limit exceeded1.083s10804 KiB
7Time limit exceeded1.088s12340 KiB
8Wrong answer363ms3120 KiB
9Wrong answer163ms2872 KiB
10Time limit exceeded1.07s20212 KiB
11Time limit exceeded1.088s13108 KiB
12Time limit exceeded1.08s9012 KiB
subtask30/15
13Wrong answer1ms316 KiB
14Wrong answer52ms996 KiB
15Wrong answer2ms316 KiB
16Wrong answer20ms568 KiB
17Wrong answer1ms316 KiB
18Wrong answer39ms820 KiB
19Wrong answer18ms412 KiB
20Wrong answer1ms316 KiB
21Wrong answer2ms316 KiB
22Wrong answer37ms820 KiB
23Wrong answer70ms1336 KiB
24Wrong answer1ms316 KiB
25Wrong answer32ms820 KiB
26Wrong answer37ms736 KiB
27Wrong answer12ms532 KiB
28Wrong answer35ms828 KiB
29Wrong answer10ms316 KiB
30Wrong answer2ms316 KiB
31Wrong answer4ms412 KiB
32Wrong answer2ms316 KiB
33Wrong answer1ms316 KiB
34Wrong answer1ms316 KiB
35Wrong answer2ms324 KiB
36Wrong answer52ms1084 KiB
37Wrong answer2ms316 KiB
38Wrong answer8ms516 KiB
subtask40/25
39Wrong answer1ms316 KiB
40Time limit exceeded1.077s6708 KiB
41Wrong answer344ms6196 KiB
42Time limit exceeded1.082s20308 KiB
43Time limit exceeded1.082s6976 KiB
44Time limit exceeded1.083s10804 KiB
45Time limit exceeded1.088s12340 KiB
46Wrong answer363ms3120 KiB
47Wrong answer163ms2872 KiB
48Time limit exceeded1.07s20212 KiB
49Time limit exceeded1.088s13108 KiB
50Time limit exceeded1.08s9012 KiB
51Wrong answer52ms996 KiB
52Wrong answer2ms316 KiB
53Wrong answer20ms568 KiB
54Wrong answer1ms316 KiB
55Wrong answer39ms820 KiB
56Wrong answer18ms412 KiB
57Wrong answer1ms316 KiB
58Wrong answer2ms316 KiB
59Wrong answer37ms820 KiB
60Wrong answer70ms1336 KiB
61Wrong answer1ms316 KiB
62Wrong answer32ms820 KiB
63Wrong answer37ms736 KiB
64Wrong answer12ms532 KiB
65Wrong answer35ms828 KiB
66Wrong answer10ms316 KiB
67Wrong answer2ms316 KiB
68Wrong answer4ms412 KiB
69Wrong answer2ms316 KiB
70Wrong answer1ms316 KiB
71Wrong answer1ms316 KiB
72Wrong answer2ms324 KiB
73Wrong answer52ms1084 KiB
74Wrong answer2ms316 KiB
75Wrong answer8ms516 KiB
76Wrong answer363ms8608 KiB
77Time limit exceeded1.078s10800 KiB
78Time limit exceeded1.078s8264 KiB
79Time limit exceeded1.083s12004 KiB
80Time limit exceeded1.075s11320 KiB
81Time limit exceeded1.08s20392 KiB
82Time limit exceeded1.08s20532 KiB
83Time limit exceeded1.072s16600 KiB
84Time limit exceeded1.085s11060 KiB
85Time limit exceeded1.1s9024 KiB
86Time limit exceeded1.1s21844 KiB
87Time limit exceeded1.088s9780 KiB
88Time limit exceeded1.082s12064 KiB
89Time limit exceeded1.1s12568 KiB
90Wrong answer897ms12380 KiB
91Time limit exceeded1.088s6964 KiB
92Wrong answer892ms12188 KiB
93Time limit exceeded1.082s7332 KiB
94Wrong answer893ms12188 KiB
95Time limit exceeded1.077s15924 KiB
96Time limit exceeded1.08s14800 KiB
97Time limit exceeded1.077s13876 KiB
98Time limit exceeded1.08s17320 KiB
99Time limit exceeded1.075s15668 KiB
100Time limit exceeded1.08s6196 KiB
101Time limit exceeded1.075s5936 KiB
102Time limit exceeded1.08s5428 KiB
103Time limit exceeded1.087s5652 KiB
104Time limit exceeded1.088s6452 KiB