Submission #499053

#TimeUsernameProblemLanguageResultExecution timeMemory
499053KarabasanZamjena (COCI18_zamjena)C++17
70 / 70
162 ms8688 KiB
#include <bits/stdc++.h> #define ll long long #define fast1 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); #define endl "\n" #define int long long using namespace std; #pragma GCC optimize("Ofast") #pragma GCC target("fma,sse,sse2,sse3,avx") #pragma GCC optimize("unroll-loops") int n,m; string a[50005]; string b[50005]; map<string,string> par; map<string,int> mark; int mal; string bul(string x) { if(par[x]==x) return x; return par[x]=bul(par[x]); } void add(string x,string y) { x=bul(x); y=bul(y); if(x==y) return; if(x[0]<='9'&&y[0]>='a') par[y]=x; else if(x[0]<='9'&&y[0]<='9') { mal=1; return; } else if(x[0]>='a'&&y[0]<='9') par[x]=y; else par[y]=par[x]; } void solve() { 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++) { par[a[i]]=a[i]; par[b[i]]=b[i]; } for(int i=0;i<n;i++) { if(a[i]==b[i]) continue; else add(a[i],b[i]); } if(mal==1) { cout<<"NE"<<endl; return; } cout<<"DA"<<endl; } signed main() { fast1 //freopen ("lca.gir","r",stdin); //freopen ("lca.cik","w",stdout); int t=1; //cin>>t; while(t--) { solve(); } 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...