# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
990708 | vjudge1 | Dijamant (COI16_dijament) | C++17 | 570 ms | 5712 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |