///A drunk man will find his way home, but a drunk bird may get lost forever...
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
//template <typename T>
//using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef tree<double, null_type, less_equal<double>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define int long long
typedef long long ll;
typedef double dd;
typedef long double ldd;
typedef pair <int, int> pii;
typedef pair <pii , int> ppii;
#define pb push_back
#define pf push_front
#define ppb pop_back()
#define ppf pop_front()
#define f first
#define s second
#define sz(x) (int)x.size()
#define smin(x , y) x = min(x , y)
#define smax(x , y) x = max(x , y)
//#define mp make_pair
#define all(x) x.begin() , x.end()
#define debug(x) cerr<< #x << " = " << x << endl
#define ddebug(x, y) cerr<< #x << " = " << x << ", " << #y << " = " << y << endl
#define uop(x, y) pii(min(x, y), max(x, y))
#define mem(a, b) memset(a, b, sizeof a)
#define sq(x) (x) * (x)
#define out return cout << "NE" << endl, 0
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math,-ffp-contract=off")
const int mx = 5e4 + 10;
vector < int > v;
map < string , string > mp;
string a[mx], b[mx];
bool is(string s){
return (s[0] >= '1' && s[0] <= '9');
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
for(int i = 0; i < n; i++)
cin >> a[i];
for(int i = 0; i < n; i++)
cin >> b[i];
for(int i = 0; i < n; i++){
if(is(a[i]) && is(b[i])){
if(a[i] != b[i])
out;
}
else if(is(a[i])){
if(mp.count(b[i]) && mp[b[i]] != a[i])
out;
mp[b[i]] = a[i];
}
else if(is(b[i])){
if(mp.count(a[i]) && mp[a[i]] != b[i])
out;
mp[a[i]] = b[i];
}
else
v.pb(i);
}
for(int u : v){
int i = u;
if(mp.count(a[i]) && mp.count(b[i])){
if(mp[a[i]] != mp[b[i]])
out;
}
else if(mp.count(a[i]))
mp[b[i]] = mp[a[i]];
else if(mp.count(b[i]))
mp[a[i]] = mp[b[i]];
else
mp[a[i]] = mp[b[i]] = '1';
}
cout << "DA" << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
3456 KB |
Output is correct |
2 |
Correct |
2 ms |
3488 KB |
Output is correct |
3 |
Correct |
3 ms |
3456 KB |
Output is correct |
4 |
Correct |
2 ms |
3456 KB |
Output is correct |
5 |
Correct |
2 ms |
3456 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
3456 KB |
Output is correct |
2 |
Correct |
3 ms |
3456 KB |
Output is correct |
3 |
Correct |
2 ms |
3456 KB |
Output is correct |
4 |
Correct |
2 ms |
3456 KB |
Output is correct |
5 |
Correct |
3 ms |
3456 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
3456 KB |
Output is correct |
2 |
Correct |
3 ms |
3456 KB |
Output is correct |
3 |
Correct |
2 ms |
3456 KB |
Output is correct |
4 |
Correct |
2 ms |
3456 KB |
Output is correct |
5 |
Correct |
2 ms |
3456 KB |
Output is correct |
6 |
Correct |
3 ms |
3456 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
3456 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
3840 KB |
Output is correct |
2 |
Incorrect |
7 ms |
3968 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |