제출 #313487

#제출 시각아이디문제언어결과실행 시간메모리
313487balbitZamjena (COCI18_zamjena)C++14
70 / 70
183 ms14456 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int, int> #define f first #define s second #ifdef BALBIT #define bug(...) cerr<<"#"<<__LINE__<<": "<<#__VA_ARGS__<<": ", _do(__VA_ARGS__) template<typename T> void _do(T && x) {cerr<<x<<endl;} template<typename T, typename ...S> void _do(T && x, S && ...y) {cerr<<x<<", "; _do(y...);} #define IOS() #else #define bug(...) #define IOS() ios::sync_with_stdio(0) #define endl '\n' #endif // BALBIT #define ALL(x) (x).begin(), (x).end() #define SZ(x) (int)((x).size()) #define pb push_back const int maxn = 1e5+5; vector<int> g[maxn]; string a[maxn], b[maxn]; bool isint(string s) { for (char c : s) { if (c < '0' || c > '9') return 0; } return 1; } map<string , int > mp; int IT=0; vector<int> hi; bool seen[maxn]; void dfs(int v) { seen[v] = 1; for (int u : g[v]) { if (!seen[u]) dfs(u); } } signed main(){ IOS(); bug(1,2); int n; cin>>n; for (int i = 0; i<n; ++i) { cin>>a[i]; if (!mp.count(a[i])) { mp[a[i]] = IT++; } } for (int i = 0; i<n; ++i) { cin>>b[i]; if (!mp.count(b[i])) { mp[b[i]] = IT++; } } for (auto & p : mp) { if (isint(p.f)) { hi.pb(p.s); } } for (int i = 0; i <n; ++i) { g[mp[a[i]]].pb(mp[b[i]]); g[mp[b[i]]].pb(mp[a[i]]); } for (int x : hi) { if (!seen[x]) { dfs(x); }else{ cout<<"NE"<<endl; return 0; } } cout<<"DA"<<endl; }
#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...