标签:namespace fir ret names code may map com alt
根据题意模拟
#include <bits/stdc++.h> #define ull unsigned long long #define P pair<int, int> #define sc(n) scanf("%d", &n) using namespace std; const int p = 131; int n, m, tot, w[100005]; vector<P> ve[100005]; map<ull, int> mp; char s[25]; P pp[55]; int main() { sc(m); for (int i = 1; i <= m; ++i) { sc(n); for (int j = 1; j <= n; ++j) { scanf("%s", s + 1); ull res = 0; for (int k = 1; s[k]; ++k) res = res * p + s[k]; if (mp.count(res)) ve[mp[res]].emplace_back(make_pair(i, j)); else mp[res] = ++tot, ve[tot].emplace_back(make_pair(i, j)); } } sc(n); int flag = 1; for (int i = 1; i <= n; ++i) { scanf("%s", s + 1); ull res = 0; for (int j = 1; s[j]; ++j) res = res * p + s[j]; if (!mp.count(res)) { flag = 0; break; } int id = mp[res]; pp[i] = ve[id][(w[id]++) % ve[id].size()]; } if (flag == 0) { puts("NOT POSSIBLE"); return 0; } for (int i = 1; i <= n; ++i) printf("%d %d\n", pp[i].first, pp[i].second); return 0; }
UCF “Practice” Local Contest — Aug 25, 2018 Call Me Maybe
标签:namespace fir ret names code may map com alt
原文地址:https://www.cnblogs.com/2aptx4869/p/12636560.html