75082024-01-09 11:47:43MagyarKendeSZLGTom és Jerry 1 (80)cpp17Time limit exceeded 0/80572ms63856 KiB

#include <bits/stdc++.h>

#pragma region Utility

#define speed cin.tie(0); ios::sync_with_stdio(0)
#define cinv(v) for (auto& e : v) cin >> e;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define size(v) (int)v.size()
#define has(s, e) s.count(e)

#define max_index(v) max_element(all(v)) - v.begin()
#define min_index(v) min_element(all(v)) - v.begin()
#define smax(x, y) x = max(x, y)
#define smin(x, y) x = min(x, y)

#define sum(v) accumulate(all(v), 0)
#define product(v, T) accumulate(all(v), 1, multiplies<T>())

using namespace std;
using ll = long long;
using point = array<int, 2>;

int max(point p) { return max(p[0], p[1]); }
int min(point p) { return min(p[0], p[1]); }

template <typename T>
vector<T> prefix_sum(const vector<T>& v) {
    vector<T> result(size(v));
    partial_sum(all(v), result.begin());
    return result;
}

#pragma endregion

int N, M, T, P, E;
vector<vector<point>> g;

void floyd_warshall(int min_width, vector<vector<int>>& distS) {
    distS.assign(N + 1, vector<int>(N + 1, INT_MAX));

    for (int i = 1; i <= N; i++) {
        distS[i][i] = 0;
    }

    for (int i = 1; i <= N; i++) {
        for (auto [j, w] : g[i]) {
            if (min_width <= w) {
                distS[i][j] = 1;
                distS[j][i] = 1;
            }
        }
    }

    for (int k = 1; k <= N; k++) {
        for (int i = 1; i <= N; i++) {
            for (int j = 1; j <= N; j++) {
                if (distS[i][k] != INT_MAX && distS[k][j] != INT_MAX) {
                    smin(distS[i][j],
                         distS[i][k] +
                         distS[k][j]
                    );
                }
            }
        }
    }
}

int main() {
    speed;

    cin >> N >> M >> T >> P >> E;

    g.resize(N + 1);

    while (M--) {
        int A, B, S;
        cin >> A >> B >> S;
    
        g[A].push_back({B, S});
        g[B].push_back({A, S});
    }

    vector<vector<int>> tom_distS, jerry_distS;

    floyd_warshall(2, tom_distS);
    // floyd_warshall(1, jerry_distS);

    while (P--) {
        int K;
        cin >> K;
        // just checking whether I fit in the time limit or not
        cout << (K & 1 ? "IGEN" : "NEM") << '\n';
    }
}
SubtaskSumTestVerdictTimeMemory
base0/80
1Accepted0/03ms1828 KiB
2Time limit exceeded0/0572ms5548 KiB
3Wrong answer0/43ms2528 KiB
4Wrong answer0/43ms2528 KiB
5Wrong answer0/44ms2784 KiB
6Wrong answer0/44ms2856 KiB
7Wrong answer0/4188ms4828 KiB
8Time limit exceeded0/4551ms6288 KiB
9Time limit exceeded0/4563ms6320 KiB
10Time limit exceeded0/4560ms18140 KiB
11Time limit exceeded0/4547ms18564 KiB
12Runtime error0/439ms63856 KiB
13Runtime error0/441ms63832 KiB
14Runtime error0/450ms63620 KiB
15Runtime error0/457ms63620 KiB
16Runtime error0/457ms63508 KiB
17Runtime error0/471ms63268 KiB
18Runtime error0/452ms63148 KiB
19Runtime error0/454ms62980 KiB
20Runtime error0/448ms62972 KiB
21Runtime error0/454ms62960 KiB
22Runtime error0/464ms62732 KiB