版本比较
题解:P13986 [PO Final 2023] 降重 / Synonyms
正文
增加 8 行删除 8 行
31 行未改动323334353636373839404041424344444546474849505051525354555657585959606162636465666767686969707171727374758 行未改动31 行未改动
int cnt1 = 0;int cnt2 = 0;
int main() int main(){
std :: cin >> n; for (int i = 1; i <= n; i++) for (int i = 1; i <= n; i++) { string a, b; std :: cin >> a >> b; if (!x[a]) if (!x[a]) { cnt1 ++; x[a] = cnt1; } word1[x[a]].push_back(b); if (!y[b]) if (!y[b]) { cnt2 ++; y[b] = cnt2; } word2[y[b]].push_back(a); }
std :: cin >> m; for (int i = 1; i <= m; i++) for (int i = 1; i <= m; i++) { string a; std :: cin >> a;
string ans = a; bool found = false;
for (auto &t : word1[x[a]]) for (auto &t : word1[x[a]]) { for (auto &s : word2[y[t]]) for (auto &s : word2[y[t]]) { if (s != a) if (s != a) { ans = s; found = true; break;8 行未改动