Submission #472218

#TimeUsernameProblemLanguageResultExecution timeMemory
472218SaraMostafaZamjena (COCI18_zamjena)C++14
70 / 70
265 ms15648 KiB
#include <bits/stdc++.h> #include<unordered_map> using namespace std; #define ll long long #define endl "\n" #define Sara ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); const long long mod=998244353; const double PI=acos(-1); map<string,bool>vs; ll cntd=0,cnta=0; map<string,vector<string>>mp; set<string>st; void dfs(string node) { vs[node]=1; if(isdigit(node[0])) st.insert(node); for(auto i:mp[node]) { if(!vs[i]) { dfs(i); } } } int main() { //freopen("input.in","r",stdin); Sara int n; cin>>n; vector<string>a(n),b(n); bool valid=1; 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++) { mp[a[i]].push_back(b[i]); mp[b[i]].push_back(a[i]); } for(int i=0; i<n; i++) { dfs(a[i]); if(st.size()>1){ valid=0; break; } st.clear(); } if(!valid) cout<<"NE"<<endl; else cout<<"DA"<<endl; 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...