Submission #197857

#TimeUsernameProblemLanguageResultExecution timeMemory
197857Osama_AlkhodairyZamjena (COCI18_zamjena)C++17
42 / 70
40 ms3064 KiB
#include <bits/stdc++.h> using namespace std; #define finish(x) return cout << x << endl, 0 #define ll long long int n; vector <string> a, b; bool num(string &x){ return '0' <= x[0] && x[0] <= '9'; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; a.resize(n); for(auto &i : a) cin >> i; b.resize(n); for(auto &i : b) cin >> i; map <string, string> m; for(int itt = 0 ; itt < 2 ; itt++){ for(int i = 0 ; i < n ; i++){ int g = num(a[i]), h = num(b[i]); if(g && h){ if(a[i] != b[i]) finish("NE"); } else if(g && !h){ if(m.count(b[i]) && m[b[i]] != a[i]) finish("NE"); m[b[i]] = a[i]; } else if(!g && h){ if(m.count(a[i]) && m[a[i]] != b[i]) finish("NE"); m[a[i]] = b[i]; } else{ g = m.count(a[i]); h = m.count(b[i]); if(g && h && m[a[i]] != m[b[i]]) finish("NE"); if(!g && h) m[a[i]] = m[b[i]]; if(g && !h) m[b[i]] = m[a[i]]; } } } cout << "DA" << endl; }
#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...