답안 #52312

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
52312 2018-06-25T09:30:26 Z Milki Dijamant (COI16_dijament) C++14
13 / 100
302 ms 3080 KB
#include <bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for(int i = 0; i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cerr << #x << " = " << x << endl
#define _ << " " <<

typedef long long ll;
typedef pair<int, int> point;

const int MAXN = 1e3 + 5;

int n;
map<string, int> id;
vector <int> parents[MAXN];
bool bio[MAXN];
int curr;

bool check(string &name, vector <string> &par){
    if(id[name] != 0) return 0;
    for(auto it : par){
        if(id[it] == 0)
            return 0;
    }
    vector <int> parId;
    REP(i, (int)par.size()){
        parId.push_back(id[par[i]]);
    }
    sort(parId.rbegin(), parId.rend());

    memset(bio, 0, sizeof(bio));
    for(auto it : parId){
        if(bio[it]) continue;

        for(auto p : parents[it]){
            if(bio[p]) return 0;
            bio[p] = 1;
        }
    }

    id[name] = ++curr;
    for(auto it : parId)
        bio[it] = 1;

    FOR(i, 1, curr)
        if(bio[i])
            parents[curr].push_back(i);
}

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

    cin >> n;
    REP(i, n){
        string name, tmp;
        vector<string> v;
        cin >> name >> tmp;
        cin >> tmp;
        while(tmp != ";"){
            v.push_back(tmp);
            cin >> tmp;
        }

        if(check(name, v))
            cout << "ok\n";
        else
            cout << "greska\n";
    }
}

Compilation message

dijament.cpp: In function 'bool check(std::__cxx11::string&, std::vector<std::__cxx11::basic_string<char> >&)':
dijament.cpp:49:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 428 KB Output is correct
4 Correct 2 ms 588 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 428 KB Output is correct
4 Correct 2 ms 588 KB Output is correct
5 Correct 2 ms 588 KB Output is correct
6 Incorrect 5 ms 592 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 428 KB Output is correct
4 Correct 2 ms 588 KB Output is correct
5 Correct 2 ms 588 KB Output is correct
6 Incorrect 5 ms 592 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 302 ms 3080 KB Output isn't correct
2 Halted 0 ms 0 KB -