답안 #620243

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
620243 2022-08-03T04:18:21 Z MinaRagy06 Zamjena (COCI18_zamjena) C++17
70 / 70
156 ms 16152 KB
#include <bits/stdc++.h>
using namespace std;
#define lesgooo ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl    '\n'
#define int     long long

map<string, vector<string>> adj;
set<string> vis;
int cur= -1;
bool ok = 1;
void dfs(string i)
{
    if (!ok) return;
    vis.insert(i);
    bool isnum = 1;
    for (auto x : i) if (x < '0' || x > '9') {isnum = 0; break;}
    if (isnum)
    {
        int num = 0;
        for (auto x : i) num = num*10 + (x-'0');
        if (cur == -1 || cur == num ) cur = num;
        else ok = 0;
    }
    for (auto nxt : adj[i]) if (vis.find(nxt) == vis.end()) dfs(nxt);
}
signed main()
{
    lesgooo;
    int n;
    cin >> n;
    vector<string> a(n), b(n);
    for (auto &i : a) cin >> i;
    for (auto &i : b) cin >> i;
    for (int i = 0; i < n; i++) adj[a[i]].push_back(b[i]), adj[b[i]].push_back(a[i]);
    for (auto i : adj)
    {
        if (vis.find(i.first) == vis.end()) cur = -1, dfs(i.first);
        if (!ok) break;
    }
    cout << (ok? "DA" : "NE");
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 324 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 596 KB Output is correct
2 Correct 2 ms 468 KB Output is correct
3 Correct 3 ms 980 KB Output is correct
4 Correct 3 ms 1100 KB Output is correct
5 Correct 5 ms 1300 KB Output is correct
6 Correct 3 ms 980 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 2900 KB Output is correct
2 Correct 40 ms 5960 KB Output is correct
3 Correct 35 ms 7852 KB Output is correct
4 Correct 48 ms 9784 KB Output is correct
5 Correct 156 ms 16152 KB Output is correct
6 Correct 114 ms 12116 KB Output is correct