# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
100383 | cvele | Zamjena (COCI18_zamjena) | C++14 | 158 ms | 11128 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
using namespace std;
const int N = 100005;
int n;
string a[N], b[N];
int cnt = 1;
int p[N];
int what[N];
map <string, int> id;
int fs(int u) {
return (p[u] == u ? u : p[u] = fs(p[u]));
}
void join(int x, int y) {
int aa = fs(x), bb = fs(y);
if (aa == bb) return;
if (what[aa] && what[bb] && (what[aa] != what[bb])) {
cout << "NE" << endl;
exit(0);
}
if (!what[aa]) {
p[aa] = bb;
} else {
p[bb] = aa;
}
}
int tonum(string a) {
int ans = 0;
for (int i = 0; i < a.size(); i++) {
ans = ans * 10 + (a[i] - '0');
}
return ans;
}
int main() {
cin >> n;
for (int i = 0; i < N; i++) p[i] = i;
for (int i = 0; i < n; i++) {
cin >> a[i];
if (!id[a[i]]) {
id[a[i]] = cnt++;
}
if (isdigit(a[i][0])) {
what[id[a[i]]] = tonum(a[i]);
}
}
for (int i = 0; i < n; i++) {
cin >> b[i];
if (!id[b[i]]) {
id[b[i]] = cnt++;
}
if (isdigit(b[i][0])) {
what[id[b[i]]] = tonum(b[i]);
}
}
for (int i = 0; i < n; i++) {
join(id[a[i]], id[b[i]]);
}
cout << "DA" << endl;
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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |