Submission #313493

#TimeUsernameProblemLanguageResultExecution timeMemory
313493PixelCatZamjena (COCI18_zamjena)C++14
28 / 70
14 ms1024 KiB
/* _____ __ __ /^--^\ | () )\ \/ / \____/ |_()_) |__| / \ _____ _ __ __ ____ _ ____ ____ _____ | || ()_)| |\ \/ /| ===|| |__ / (__` / () \|_ _| \__ __/ |_| |_|/_/\_\|____||____|\____)/__/\__\ |_| |^|^\ \^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^|^| | | |\ \| | | | | | | | | | | | | | | | | | | | | | | | | #####/ /################################################# | | |\/ | | | | | | | | | | | | | | | | | | | | | | | | | |_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_| | #include <Orz/i_am_noob.h> #include <Orz/balbit.h> #include <Orz/nathanlee726.h>*/ #include <bits/stdc++.h> using namespace std; using ll=long long; using ull=unsigned long long; using pii=pair<ll,ll>; #define int ll #define For(i,a,b) for(int i=a;i<=b;i++) #define Forr(i,a,b) for(int i=a;i>=b;i--) #define F first #define S second #define eb emplace_back #define all(x) x.begin(),x.end() #define sz(x) ((int)x.size()) #define mkp make_pair #define MOD (ll)(1e9+7) #define INF (1e18) #define EPS (1e-6) #ifdef LOCALMEOW #define debug(...) do{\ cerr << __PRETTY_FUNCTION__ << " - " << __LINE__ <<\ " : ("#__VA_ARGS__ << ") = ";\ _OUT(__VA_ARGS__);\ }while(0) template<typename T> void _OUT(T x) { cerr << x << "\n"; } template<typename T,typename...I> void _OUT(T x,I ...tail) { cerr << x << ", "; _OUT(tail...); } #else #define debug(...) #endif void INIT(){ ios::sync_with_stdio(false); cin.tie(0); } int gcd(int a,int b) { return b==0?a:gcd(b,a%b); } int lcm(int a,int b) { return a/gcd(a,b)*b; } int fpow(int b,int p){ int ans=1,now=b; while(p){ if(p&1) ans=ans*now%MOD; p/=2; now=now*now%MOD; } return ans; } map<string,int> mp; struct DSU{ int p[50050]; int cnt[50050]; void init(int n,int k){ p[n]=n; cnt[n]=k; } int find(int n){ if(p[n]==n) return n; return p[n]=find(p[n]); } bool uni(int a,int b){ a=find(a); b=find(b); if(a!=b){ p[a]=b; cnt[a]+=cnt[b]; } if(cnt[a]>1) return false; return true; } }dsu; int32_t main(){ INIT(); //I won't misunderstand the problem statement anymore. //I won't misunderstand the problem statement anymore. //I won't misunderstand the problem statement anymore. //I won't misunderstand the problem statement anymore. //I won't misunderstand the problem statement anymore. //I won't misunderstand the problem statement anymore. //I won't misunderstand the problem statement anymore. //I won't misunderstand the problem statement anymore. //I won't misunderstand the problem statement anymore. //I won't misunderstand the problem statement anymore. //code... int n; cin>>n; string s; vector<int> a(n),b(n); int nowid=0; For(i,0,n-1){ cin>>s; if(!mp.count(s)){ mp[s]=nowid; dsu.init(nowid,(s[0]<'a')); nowid++; } a[i]=mp[s]; } For(i,0,n-1){ cin>>s; if(!mp.count(s)){ mp[s]=nowid; dsu.init(nowid,(s[0]<'a')); nowid++; } b[i]=mp[s]; } For(i,0,n-1){ if(a[i]!=b[i]){ if(!dsu.uni(a[i],b[i])){ cout<<"NE\n"; return 0; } } } cout<<"DA\n"; 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...