이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
bool is_word (string st) {
if (st[0] >= '0' && st[0] <= '9') {
return false;
}
return true;
}
unordered_map<string, vector<int> > words1;
unordered_map<string, vector<int> > words2;
int main () {
int N;
cin >> N;
vector<string> a(N + 1);
vector<string> b(N + 1);
for (int i = 1; i <= N; i++) {
cin >> a[i];
if (is_word(a[i])) {
words1[a[i]].push_back(i);
}
}
for (int i = 1; i <= N; i++) {
cin >> b[i];
if (is_word(b[i])) {
words2[b[i]].push_back(i);
}
}
for (int i = 1; i <= N; i++) {
if (a[i] != b[i]) {
if (is_word(a[i])) {
string st = a[i];
for (int id : words1[st]) {
a[id] = b[i];
words1[b[i]].push_back(id);
}
words1[st].clear();
for (int id : words2[st]) {
b[id] = b[i];
words2[b[i]].push_back(id);
}
words2[st].clear();
}
else if (is_word(b[i])) {
string st = b[i];
for (int id : words1[st]) {
a[id] = a[i];
words1[a[i]].push_back(id);
}
words1[st].clear();
for (int id : words2[st]) {
b[id] = a[i];
words2[a[i]].push_back(id);
}
words2[st].clear();
}
else {
cout << "NE" << "\n";
return 0;
}
}
}
for (int i = 1; i <= N; i++) {
if (a[i] != b[i]) {
cout << "NE" << "\n";
return 0;
}
}
cout << "DA" << "\n";
return 0;
}
| # | 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... |