Submission #1085903

# Submission time Handle Problem Language Result Execution time Memory
1085903 2024-09-09T03:20:11 Z lmaobruh Zamjena (COCI18_zamjena) C++14
56 / 70
45 ms 65536 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fo(i, a, b) for (int i = (a); i <= (b); ++i)
#define fd(i, a, b) for (int i = (a); i >= (b); --i)
#define ii pair<int, int>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
const int N = 1e6+5;

int n, cnt = 0;
string a[N], b[N];
map<string, bool> vis;
map<string, vector<string>> g;

bool allDigit(string &s) {
    for (char c : s) if(c < '0' || c > '9') return 0;
    return 1;
}

void dfs(string u) {
    vis[u] = 1;
    cnt += allDigit(u);
    for (string &v : g[u]) if (!vis[v]) dfs(v);
}

int32_t main() {
    cin.tie(0)->sync_with_stdio(0);
    if (fopen("A.inp", "r")) {
        freopen("A.inp", "r", stdin);
//        freopen("A.out", "w", stdout);
    }
    cin >> n;
    fo(i, 1, n) cin >> a[i];
    fo(i, 1, n) cin >> b[i];
    fo(i, 1, n) if (a[i] != b[i])
        g[a[i]].pb(b[i]), g[b[i]].pb(a[i]);
    fo(i, 1, n) if (!vis[a[i]]) {
        cnt = 0;
        dfs(a[i]);
        if (cnt > 1) {
            cout << "NE";
            return 0;
        }
    }
    cout << "DA";
}

Compilation message

zamjena.cpp: In function 'int32_t main()':
zamjena.cpp:32:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |         freopen("A.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 30 ms 63064 KB Output is correct
2 Correct 30 ms 62800 KB Output is correct
3 Correct 31 ms 63052 KB Output is correct
4 Correct 29 ms 63068 KB Output is correct
5 Correct 30 ms 63064 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 63056 KB Output is correct
2 Correct 34 ms 62852 KB Output is correct
3 Correct 29 ms 63084 KB Output is correct
4 Correct 31 ms 62860 KB Output is correct
5 Correct 27 ms 62980 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 63068 KB Output is correct
2 Correct 28 ms 63068 KB Output is correct
3 Correct 30 ms 63068 KB Output is correct
4 Correct 26 ms 63068 KB Output is correct
5 Correct 28 ms 63068 KB Output is correct
6 Correct 30 ms 63064 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 63152 KB Output is correct
2 Correct 29 ms 63068 KB Output is correct
3 Correct 31 ms 63544 KB Output is correct
4 Correct 33 ms 63616 KB Output is correct
5 Correct 29 ms 63568 KB Output is correct
6 Correct 38 ms 63568 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 45 ms 65360 KB Output is correct
2 Runtime error 38 ms 65536 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -