Submission #384266

#TimeUsernameProblemLanguageResultExecution timeMemory
384266AdiZer0Zamjena (COCI18_zamjena)C++17
14 / 70
1079 ms3948 KiB
#include <bits/stdc++.h> #define pb push_back #define whole(x) x.begin(), x.end() #define sz(x) (int)x.size() using namespace std; typedef long long ll; typedef long double ld; const int N = (int)5e4 + 7; const int INF = (int)1e9 + 7; const ll linf = (ll)1e18 + 1; string a[N], b[N]; string make_string(int x) { string res; while (x) { res += (char((x % 10) + '0')); x /= 10; } reverse(whole(res)); return res; } int main() { int n; cin >> n; set<string> all; for (int i = 1; i <= n; ++i) { cin >> a[i]; if ('a' <= a[i][0] && a[i][0] <= 'z') all.insert(a[i]); } for (int i = 1; i <= n; ++i) { cin >> b[i]; if ('a' <= b[i][0] && b[i][0] <= 'z') all.insert(b[i]); } for (auto to : all) { bool f = 0; for (int x = 1; x <= 1000; ++x) { bool good = 1; for (int i = 1; i <= n; ++i) { string cur1 = a[i], cur2 = b[i]; if (cur1 == to || cur2 == to) { if (cur1 == to) cur1 = make_string(x); if (cur2 == to) cur2 = make_string(x); if (('a' <= cur1[0] && cur1[0] <= 'z') || ('a' <= cur2[0] && cur2[0] <= 'z')) continue; if (cur1 != cur2) good = 0; } } if (good) { for (int i = 1; i <= n; ++i) { if (a[i] == to) a[i] = make_string(x); if (b[i] == to) b[i] = make_string(x); } f = 1; break; } } if (!f) return cout << "NE\n", 0; } cout << "DA\n"; return 0; } /* 5 x 3 x y 3 x y 2 z 3 */
#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...