답안 #743628

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
743628 2023-05-17T14:52:26 Z lukadupli Dijamant (COI16_dijament) C++14
56 / 100
2000 ms 420 KB
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1005;

int n, cnt = 0;
map<string, int> mapa;
bitset<MAXN> bs[MAXN];

bool add(string& klasa, vector<string>& dads){
    if(mapa.find(klasa) != mapa.end()) return 0;
    for(string& d : dads) if(mapa.find(d) == mapa.end()) return 0;

    bitset<MAXN> b;
    for(int i = 0; i < dads.size(); i++){
        for(int j = i + 1; j < dads.size(); j++){
            int d1 = mapa[dads[i]], d2 = mapa[dads[j]];
            if(!bs[d2][d1] && !bs[d1][d2] && (bs[d1] & bs[d2]).count()) return 0;
        }
        b |= bs[mapa[dads[i]]];
    }

    mapa[klasa] = ++cnt;
    b[cnt] = 1;
    bs[cnt] = b;

    return 1;
}

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

    cin >> n;
    for(int i = 0; i < n; i++){
        string k;
        cin >> k;

        char c;
        cin >> c;

        vector<string> dads;
        string in = "";
        while(in != ";"){
            cin >> in;
            dads.push_back(in);
        }
        dads.pop_back();

        if(add(k, dads)) cout << "ok\n";
        else cout << "greska\n";
    }

	return 0;
}

Compilation message

dijament.cpp: In function 'bool add(std::string&, std::vector<std::__cxx11::basic_string<char> >&)':
dijament.cpp:16:22: 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]
   16 |     for(int i = 0; i < dads.size(); i++){
      |                    ~~^~~~~~~~~~~~~
dijament.cpp:17:30: 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]
   17 |         for(int j = i + 1; j < dads.size(); j++){
      |                            ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 22 ms 348 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 22 ms 348 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2089 ms 420 KB Time limit exceeded
2 Halted 0 ms 0 KB -