제출 #82259

#제출 시각아이디문제언어결과실행 시간메모리
82259MilkiZamjena (COCI18_zamjena)C++14
14 / 70
16 ms5740 KiB
#include<bits/stdc++.h> using namespace std; #define FOR(i, a, b) for(int i = a; i < b; ++i) #define REP(i, n) FOR(i, 0, n) #define _ << " " << #define sz(x) ((int) x.size()) #define pb(x) push_back(x) typedef long long ll; typedef pair<int, int> point; const int MAXN = 5e4 + 5; unordered_map<string, string> val; unordered_map<string, vector<string> > isti; int n; string a[MAXN], b[MAXN]; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cin >> n; REP(i, n) cin >> a[i]; REP(i, n) cin >> b[i]; REP(i, n){ if(a[i][0] >= '0' && a[i][0] <= '9' && b[i][0] >= '0' && b[i][0] <= '9'){ if(a[i] != b[i]){ cout << "NE\n"; return 0; } } else if( (a[i][0] >= '0' && a[i][0] <= '9') || (b[i][0] >= '0' && b[i][0] <= '9')){ if(b[i][0] >= '0' && b[i][0] <= '9') swap(a[i], b[i]); val[a[i]] = b[i]; for(auto it : isti[a[i]]){ val[it] = b[i]; for(auto it2 : isti[it]) val[it2] = b[i]; isti[it].clear(); } isti[a[i]].clear(); } else{ string val_a = val[a[i]], val_b = val[b[i]]; if(val_a == "") { swap(val_a, val_b); swap(a[i], b[i]); } if(val_a == "" && val_b == ""){ isti[a[i]].pb(b[i]); isti[b[i]].pb(a[i]); } else if(val_a != "" && val_b == ""){ for(auto it : isti[b[i]]){ val[it] = val_a; for(auto it2 : isti[it]) val[it2] = val_a; isti[it].clear(); } isti[b[i]].clear(); } else if(val_a != val_b){ cout << "NE\n"; return 0; } } } cout << "DA\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...