# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
464634 | aihay | Zamjena (COCI18_zamjena) | C++14 | 266 ms | 44208 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.
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("-Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef int in;
#define int long long
#define f first
#define s second
#define pb push_back
#define pp push
#define double long double
#define ceil(x,y) (x/y)+(x%y!=0)*((double)(1.0*x/y)<0?0:1)
#define floor(x,y) (x/y)+(x%y!=0)*((double)(1.0a*x/y)<0?-1:0)
const int MAX=1e7;
const int MOD=1e9+7;
const int MAAX=1e18;
string arr[500010],arr2[500010];
map<string,vector<string> >mp;
map<string,int> vis;
set<string> fun(string idx){
set<string> ans;
if(vis[idx])
return ans;
vis[idx]=1;
for(int i=0;i<mp[idx].size()&&ans.size()<2;i++){
set<string>x=fun(mp[idx][i]);
set<string>::iterator it;
for(it=x.begin();it!=x.end()&&ans.size()<2;it++){
ans.insert(*it);
}
}
if(idx[0]>='0'&&idx[0]<='9')
ans.insert(idx);
return ans;
}
in main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int tc=1;
//cin>>tc;
while(tc--){
int n;
cin>>n;
for(int i=0;i<n;i++){
cin>>arr[i];
}
for(int i=0;i<n;i++){
string s;
cin>>s;
arr2[i]=s;
mp[arr[i]].pb(s);
mp[s].pb(arr[i]);
}
bool bol=1;
for(int i=0;i<n;i++){
bol&=(fun(arr[i]).size()>1?0:1);
bol&=(fun(arr2[i]).size()>1?0:1);
}
cout<<(bol?"DA\n":"NE\n");
}
}
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... |