# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
779069 | vjudge1 | Zamjena (COCI18_zamjena) | C++17 | 92 ms | 9868 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);
#define OYY 1000000005
#define mod 998244353
map <string,int> mp;
bool vis[50005];
int tut=0;
vector <int> v;
vector <int> vt[50005];
inline void dfs(int node){
vis[node]=1;
for(int i=0;i<vt[node].size();i++){
if(!vis[vt[node][i]])dfs(vt[node][i]);
}
}
int32_t main(){
faster
memset(vis,0,sizeof(vis));
int n;cin>>n;
string dizi[n],dizi1[n];
for(int i=0;i<n;i++){
cin>>dizi[i];
if(!mp.count(dizi[i])){
mp[dizi[i]]=tut;
tut++;
}
}
for(int i=0;i<n;i++){
cin>>dizi1[i];
if(!mp.count(dizi1[i])){
mp[dizi1[i]]=tut;
tut++;
}
}
for(int i=0;i<n;i++){
vt[mp[dizi[i]]].push_back(mp[dizi1[i]]);
vt[mp[dizi1[i]]].push_back(mp[dizi[i]]);
}
map<string,int> ::iterator it=mp.begin();
while(it!=mp.end()){
string su=it->first;
if(su[0]>='0' && su[0]<='9'){
v.push_back(it->second);
}
it++;
}
bool stop=true;
for(int i=0;i<v.size() && stop;i++){
if(!vis[v[i]])dfs(v[i]);
else stop=false;
}
if(stop)cout<<"DA"<<'\n';
else cout<<"NE"<<'\n';
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |