Submission #87014

#TimeUsernameProblemLanguageResultExecution timeMemory
87014minhtri5302Zamjena (COCI18_zamjena)C++14
28 / 70
27 ms4604 KiB
//Trương Minh Trí #include <bits/stdc++.h> #define FOR(i, x, y) for(int i = x; i <= y; ++i) #define FORN(i, x, y) for(int i = x; i >= y; --i) #define Task "Zamjena" #define maxn 50005 #define maxm #define emlacongchuacuaanh 1302 #define pii pair <int, int> #define pll pair <long long, long long> #define pb push_back #define mp make_pair #define F first #define S second #define reset(x) memset(x, 0, sizeof(x)); using namespace std; int n; string a[maxn], b[maxn]; bool ok(string x) { return (x[0] >= '0' && x[0] <= '9'); } map<string, string> mm; int save[maxn], cnt; int save1[maxn], cnt1; int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); //freopen(Task".inp", "r", stdin); //freopen(Task".out", "w", stdout); cin >> n; FOR(i, 1, n) cin >> a[i]; FOR(i, 1, n) cin >> b[i]; FOR(i, 1, n) { if(!ok(a[i]) && !ok(b[i])) { save[++cnt] = i; continue; } if(ok(a[i]) && ok(b[i])) { if(a[i] == b[i]) continue; else return cout <<"NE", 0; } if(ok(a[i]) && !ok(b[i])) { if(mm[b[i]] =="") mm[b[i]] = a[i]; else if(mm[b[i]] != a[i]) return cout <<"NE", 0; } if(!ok(a[i]) && ok(b[i])) { if(mm[a[i]] == "") mm[a[i]] = b[i]; else if(mm[a[i]] != b[i]) return cout <<"NE", 0; } } FOR(i, 1, cnt) { int pos = save[i]; if(mm[a[pos]] != "" && mm[b[pos]] != "") { if(mm[a[pos]] == mm[b[pos]]) continue; else return cout <<"NE", 0; } else if(mm[a[pos]] =="" && mm[b[pos]] == "") { save1[++cnt1] = pos; continue; } else if(mm[b[i]] != "" ) mm[a[i]] == mm[b[i]]; else mm[b[i]] == mm[a[i]]; } FOR(i, 1, cnt1) { int pos = save1[i]; if(mm[a[pos]] != "" && mm[b[pos]] != "") { if(mm[a[pos]] == mm[b[pos]]) continue; else return cout <<"NE", 0; } else if(mm[a[pos]] =="" && mm[b[pos]] == "") { mm[a[i]] = mm[b[i]] = "HVH"; } else if(mm[b[i]] != "" ) mm[a[i]] == mm[b[i]]; else mm[b[i]] == mm[a[i]]; } cout << "DA"; } template <typename T> inline void read(T &x){char c;bool nega=0;while((!isdigit(c=getchar()))&&(c!='-'));if(c=='-'){nega=1;c=getchar();}x=c-48;while(isdigit(c=getchar())) x=x*10+c-48;if(nega) x=-x;} template <typename T> inline void writep(T x){if(x>9) writep(x/10);putchar(x%10+48);} template <typename T> inline void write(T x){if(x<0){putchar('-');x=-x;}writep(x);putchar(' ');} template <typename T> inline void writeln(T x){write(x);putchar('\n');}
#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...