# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
145143 | Sarah_Mokhtar | Zamjena (COCI18_zamjena) | C++14 | 16 ms | 6656 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;
typedef long long ll;
const int N=1e5+20,M=(N<<4),OO=1e9;
#define f first
#define s second
#define pb push_back
#define sz size
#define l length
ll n;
string A[N],B[N];
map<string,int>m;
bool isNumber(string c){
//cout<<c<<" ";
char cmp=c[0];
return cmp>='0'&&cmp<='9';
}
bool valid(){
for(int i=0;i<n;++i){
if(isNumber(B[i])&&isNumber(A[i])){
if(A[i]!=B[i]){
return 0;
}
}else if(isNumber(A[i])&&!m[B[i]])
m[B[i]]=stoi(A[i]);
//cout<<1;
else if(isNumber(B[i])&&!m[A[i]])
m[A[i]]=stoi(B[i]);
else if(isNumber(A[i])&&m[B[i]])
if(m[B[i]]!=stoi(A[i])) return 0;
else if(isNumber(B[i])&&m[A[i]])
if(m[A[i]]!=stoi(B[i])) return 0;
//cout<<m["x"];
}
return 1;
}
int main(){
cin>>n;
for(int i=0;i<n;++i) cin>>A[i];
for(int i=0;i<n;++i) cin>>B[i];
puts(valid()?"DA":"NE");
}
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... |