Submission #963457

# Submission time Handle Problem Language Result Execution time Memory
963457 2024-04-15T03:51:33 Z riariti Dijamant (COI16_dijament) C++17
100 / 100
1597 ms 4724 KB
#include <bits/stdc++.h>

namespace MX {

constexpr int N = 1E3 + 9;

}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int N;
    std::cin >> N;

    std::map<std::string, int> cc;
    std::vector anc(N, std::bitset<MX::N>(0));
    for (int k = 0; k < N; k++) {
        std::string K;
        std::cin >> K;

        bool bad = cc.count(K);

        std::vector<int> P;

        std::string s;
        std::cin >> s;
        while (true) {
            std::cin >> s;
            if (s == ";") {
                break;
            }

            if (!cc.count(s)) {
                bad = true;
                continue;
            }

            auto v = cc[s];
            P.push_back(v);

            anc[k] |= anc[v];
            anc[k][v] = true;
        }

        for (int i = 0; i < P.size() && !bad; i++) {
            for (int j = i + 1; j < P.size() && !bad; j++) {
                auto u = P[i];
                auto v = P[j];

                auto f = anc[u] & anc[v];
                if (f.any()) {
                    bad |= !(anc[u][v] || anc[v][u]);
                }
            }
        }

        if (bad) {
            std::cout << "greska\n";
            continue;
        }

        std::cout << "ok\n";
        cc[K] = k;
    }

    return 0;
}

Compilation message

dijament.cpp: In function 'int main()':
dijament.cpp:46:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |         for (int i = 0; i < P.size() && !bad; i++) {
      |                         ~~^~~~~~~~~~
dijament.cpp:47:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |             for (int j = i + 1; j < P.size() && !bad; j++) {
      |                                 ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 600 KB Output is correct
6 Correct 3 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 600 KB Output is correct
6 Correct 3 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 600 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1313 ms 4436 KB Output is correct
2 Correct 1597 ms 4724 KB Output is correct
3 Correct 62 ms 4692 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 3 ms 604 KB Output is correct
7 Correct 6 ms 804 KB Output is correct
8 Correct 11 ms 856 KB Output is correct
9 Correct 13 ms 860 KB Output is correct
10 Correct 4 ms 604 KB Output is correct
11 Correct 3 ms 712 KB Output is correct
12 Correct 1191 ms 3960 KB Output is correct