# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
159683 | socho | Zamjena (COCI18_zamjena) | C++14 | 300 ms | 65540 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
using namespace std;
map<string, vector<string> > adj;
map<string, bool> vis;
bool isn(string s) {
char x = s[0];
if (x >= '0' && x <= '9') return true;
return false;
}
int dfsw(string s, string last) {
int count = isn(s);
vis[s] = true;
for (int i=0; i<adj[s].size(); i++) {
string other = adj[s][i];
if (other == last) continue;
if (other == s) continue;
count += dfsw(other, s);
}
return count;
}
int main() {
int n;
cin >> n;
string a1[n], a2[n];
for (int i=0; i<n; i++) cin >> a1[i];
for (int i=0; i<n; i++) cin >> a2[i];
for (int i=0; i<n; i++) {
string a = a1[i], b = a2[i];
adj[a].push_back(b);
adj[b].push_back(a);
}
for (int i=0; i<n; i++) {
string a = a1[i];
if (!vis[a]) {
int re = dfsw(a, "");
// cout << a << ' ' << re << endl;
if (re > 1) {
cout << "NE" << endl;
exit(0);
}
}
}
cout << "DA" << endl;
exit(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... |