Submission #990708

# Submission time Handle Problem Language Result Execution time Memory
990708 2024-05-31T05:08:49 Z vjudge1 Dijamant (COI16_dijament) C++17
100 / 100
570 ms 5712 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 1005;
int n;
bool derived[N][N], sibling[N][N];
map<string, int> mp;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    cin >> n;
    for (int ii = 0; ii < n; ii ++){
        string inp;
        cin >> inp;
        
        vector<string> vecs;
        while (inp != ";"){
            if (inp != ":")
                vecs.push_back(inp);
            cin >> inp;
        }

        bool good = 1;
        if (mp.find(vecs[0]) != mp.end()){
            // cout << vecs[0] << " was already there" << endl;
            good = 0;
        }
        for (int i = 1; i < vecs.size(); i ++){
            if (mp.find(vecs[i]) == mp.end()){
                // cout << vecs[i] << " was not found" << endl;
                good = 0;
            }
        }

        if (!good){
            cout << "greska" << endl;
            continue;
        }

        vector<int> vec;
        for (int i = 1; i < vecs.size(); i ++)
            vec.push_back(mp[vecs[i]]);

        for (int i = 0; i < vec.size(); i ++){
            for (int j = i + 1; j < vec.size(); j ++){
                if (sibling[vec[i]][vec[j]]){
                    // cout << vec[i] << " and " << vec[j] << " are siblings" << endl;
                    good = 0;
                }
            }
        }

        if (!good){
            cout << "greska" << endl;
            continue;
        }

        cout << "ok" << endl;

        int cur = mp.size();
        mp[vecs[0]] = cur;

        for (int j : vec)
            derived[cur][j] = 1;

        for (int i = 0; i < cur; i ++)
            for (int j : vec)
                derived[cur][i] |= derived[j][i];

        for (int i = 0; i < cur; i ++){
            if (derived[cur][i]) continue;
            for (int j = 0; j < cur; j ++)
                if (derived[i][j] and derived[cur][j])
                    sibling[cur][i] = sibling[i][cur] = 1;
        }
    }
}

Compilation message

dijament.cpp: In function 'int main()':
dijament.cpp:30:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |         for (int i = 1; i < vecs.size(); i ++){
      |                         ~~^~~~~~~~~~~~~
dijament.cpp:43:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |         for (int i = 1; i < vecs.size(); i ++)
      |                         ~~^~~~~~~~~~~~~
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 < vec.size(); 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 < vec.size(); j ++){
      |                                 ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 600 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 600 KB Output is correct
10 Correct 1 ms 344 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 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 604 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 344 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 482 ms 1360 KB Output is correct
2 Correct 570 ms 5712 KB Output is correct
3 Correct 60 ms 4500 KB Output is correct
4 Correct 8 ms 860 KB Output is correct
5 Correct 59 ms 1532 KB Output is correct
6 Correct 25 ms 1304 KB Output is correct
7 Correct 30 ms 1364 KB Output is correct
8 Correct 42 ms 1616 KB Output is correct
9 Correct 34 ms 1576 KB Output is correct
10 Correct 20 ms 1116 KB Output is correct
11 Correct 22 ms 1360 KB Output is correct
12 Correct 495 ms 4712 KB Output is correct