# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
105492 | JakubLap | Palinilap (COI16_palinilap) | C++17 | 3 ms | 512 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N = 1024;
map<long long, int> ID;
bitset<N> a[N];
int n;
long long getCode(string s) {
long long ans = 0;
for (int i = 0; i < s.size(); ++i)
ans = ans * 26 + (s[i] - 'a');
return ans;
}
int main() {
ios::sync_with_stdio(false);
int nQuery; cin >> nQuery;
while (nQuery--) {
string u; cin >> u;
long long u_code = getCode(u);
char colon; cin >> colon;
string v;
vector<int> adj;
bool fail = ID.count(u_code);
while (cin >> v) {
if (v == ";") break;
long long code = getCode(v);
if (!ID.count(code)) {
fail = true;
} else {
adj.push_back(ID[code]);
}
}
if (fail) {
cout << "greska\n";
continue;
}
sort(adj.begin(), adj.end(), greater<int>());
bitset<N> was;
for (int i = 0; i < adj.size(); ++i) {
int v = adj[i];
bool isRoot = true;
for (int j = 0; j < i; ++j) if (a[adj[j]].test(v)) {
isRoot = false;
break;
}
if (isRoot) {
if ((was & a[v]).any()) {
fail = true;
break;
}
was |= a[v];
}
}
if (fail) {
cout << "greska\n";
continue;
}
cout << "ok\n";
ID[u_code] = ++n;
for (int v : adj) {
a[n] |= a[v];
a[n].set(v);
}
}
return 0;
}
컴파일 시 표준 에러 (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... |