码迷,mamicode.com
首页 > 其他好文 > 详细

UCF “Practice” Local Contest — Aug 25, 2018 Call Me Maybe

时间:2020-04-05 13:39:22      阅读:70      评论:0      收藏:0      [点我收藏+]

标签: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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!