Submission #385253

#TimeUsernameProblemLanguageResultExecution timeMemory
385253penguinhackerZamjena (COCI18_zamjena)C++14
28 / 70
8 ms3820 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define ar array int n; string a[50000], b[50000]; map<string, int> mp; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n; for (int i = 0; i < n; ++i) cin >> a[i]; for (int i = 0; i < n; ++i) cin >> b[i]; for (int i = 0; i < n; ++i) { if (a[i] == b[i]) continue; if (isdigit(a[i][0]) && isdigit(b[i][0])) { cout << "NE"; return 0; } else if (isdigit(a[i][0]) && isalpha(b[i][0])) { int x = stoi(a[i]); auto it = mp.find(b[i]); if (it == mp.end()) mp[b[i]] = x; else if (it->second ^ x) { cout << "NE"; return 0; } } else if (isalpha(a[i][0]) && isdigit(b[i][0])) { int x = stoi(b[i]); auto it = mp.find(a[i]); if (it == mp.end()) mp[a[i]] = x; else if (it->second ^ x) { cout << "NE"; return 0; } } } for (int i = 0; i < n; ++i) if (isalpha(a[i][0]) && isalpha(b[i][0]) && a[i] != b[i] && mp[a[i]] != mp[b[i]]) { cout << "NE"; return 0; } cout << "DA"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...