200092025-12-31 00:20:05szabelrBizonyításcpp17Accepted 50/50289ms1692 KiB
// Bizonyítás.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>

using namespace std;

bool elerheto[501][501];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, q;
    if (!(cin >> n >> q)) return 0;
    for (int i = 1; i <= n; i++) {
        elerheto[i][i] = true;
    }
    for (int i = 0; i < q; i++) {
        int t, x, y;
        cin >> t >> x >> y;

        if (t == 2) {
            if (elerheto[x][y]) 
                cout << "IGEN\n";
            else 
                cout << "NEM\n";
        }
        else {
            if (elerheto[x][y]) continue;
            vector<int> elodok;
            for (int j = 1; j <= n; j++) {
                if (elerheto[j][x]) {
                    elodok.push_back(j);
                }
            }
            vector<int> utodok;
            for (int j = 1; j <= n; j++) {
                if (elerheto[y][j]) {
                    utodok.push_back(j);
                }
            }
            for (int forras : elodok) {
                for (int cel : utodok) {
                    elerheto[forras][cel] = true;
                }
            }
        }
    }

    return 0;
}
// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted1ms316 KiB
2Accepted82ms1072 KiB
subtask210/10
3Accepted2ms316 KiB
4Accepted4ms316 KiB
5Accepted34ms564 KiB
6Accepted19ms628 KiB
7Accepted20ms564 KiB
8Accepted2ms316 KiB
9Accepted1ms316 KiB
10Accepted7ms316 KiB
11Accepted16ms608 KiB
12Accepted26ms664 KiB
subtask315/15
13Accepted1ms500 KiB
14Accepted1ms316 KiB
15Accepted1ms316 KiB
16Accepted1ms316 KiB
17Accepted1ms316 KiB
18Accepted1ms316 KiB
19Accepted2ms316 KiB
20Accepted1ms316 KiB
21Accepted1ms316 KiB
22Accepted1ms332 KiB
23Accepted1ms316 KiB
24Accepted1ms316 KiB
25Accepted1ms316 KiB
26Accepted1ms316 KiB
27Accepted1ms316 KiB
28Accepted1ms316 KiB
29Accepted2ms332 KiB
30Accepted2ms316 KiB
31Accepted2ms500 KiB
32Accepted2ms556 KiB
33Accepted1ms316 KiB
34Accepted1ms316 KiB
35Accepted1ms316 KiB
36Accepted2ms552 KiB
37Accepted1ms508 KiB
38Accepted1ms316 KiB
subtask425/25
39Accepted1ms500 KiB
40Accepted82ms1076 KiB
41Accepted2ms316 KiB
42Accepted4ms316 KiB
43Accepted34ms564 KiB
44Accepted19ms628 KiB
45Accepted20ms564 KiB
46Accepted2ms316 KiB
47Accepted1ms316 KiB
48Accepted7ms316 KiB
49Accepted16ms608 KiB
50Accepted26ms664 KiB
51Accepted1ms316 KiB
52Accepted1ms316 KiB
53Accepted1ms316 KiB
54Accepted1ms316 KiB
55Accepted1ms316 KiB
56Accepted2ms316 KiB
57Accepted1ms316 KiB
58Accepted1ms316 KiB
59Accepted1ms332 KiB
60Accepted1ms316 KiB
61Accepted1ms316 KiB
62Accepted1ms316 KiB
63Accepted1ms316 KiB
64Accepted1ms316 KiB
65Accepted1ms316 KiB
66Accepted2ms332 KiB
67Accepted2ms316 KiB
68Accepted2ms500 KiB
69Accepted2ms556 KiB
70Accepted1ms316 KiB
71Accepted1ms316 KiB
72Accepted1ms316 KiB
73Accepted2ms552 KiB
74Accepted1ms508 KiB
75Accepted1ms316 KiB
76Accepted21ms844 KiB
77Accepted14ms604 KiB
78Accepted64ms948 KiB
79Accepted12ms564 KiB
80Accepted45ms820 KiB
81Accepted19ms564 KiB
82Accepted20ms564 KiB
83Accepted17ms608 KiB
84Accepted28ms764 KiB
85Accepted48ms724 KiB
86Accepted34ms1076 KiB
87Accepted46ms816 KiB
88Accepted17ms644 KiB
89Accepted19ms564 KiB
90Accepted54ms1332 KiB
91Accepted64ms932 KiB
92Accepted54ms1380 KiB
93Accepted57ms920 KiB
94Accepted54ms1332 KiB
95Accepted37ms1076 KiB
96Accepted52ms820 KiB
97Accepted54ms824 KiB
98Accepted39ms1216 KiB
99Accepted54ms1076 KiB
100Accepted245ms1588 KiB
101Accepted247ms1588 KiB
102Accepted289ms1692 KiB
103Accepted289ms1584 KiB
104Accepted236ms1332 KiB