样例没过玄关
  • 板块灌水区
  • 楼主一咕咕一
  • 当前回复0
  • 已保存回复0
  • 发布时间2024/12/5 22:23
  • 上次更新2024/12/6 16:20:38
查看原帖
样例没过玄关
772815
一咕咕一楼主2024/12/5 22:23

https://www.luogu.com.cn/problem/B3851

code:

#include <bits/stdc++.h>
using namespace std;
char uke[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
int hash_code(string x)
{
    int sum = 0;
    if (x[1] <= '9' && x[1] >= '0')
        sum += (x[1] - '0') * 1;
    else
        sum += (x[1] - 'A' + 10) * 1;
    if (x[0] <= '9' && x[0] >= '0')
        sum += (x[0] - '0') * 16;
    else
        sum += (x[0] - 'A' + 10) * 16;
    return sum;
    /////////////////
}
struct chen_zhe
{
    int x, id;
    string s;
    char k;
} de[25600];
int n;
int a[27][27];
string eee[25600];
string gr[25600];
bool cmp(chen_zhe a, chen_zhe b)
{
    return (a.x != b.x ? a.x > b.x : a.id < b.id);
}
int main()
{
    // freopen(".in", "r", stdin);
    // freopen(".out", "w", stdout);
    cin >> n;
    for (int i = 0; i < 256; i++)
        de[i].id = i;
    for (int i = 0; i < n; i++)
    {
        string r;
        cin >> r;
        eee[i] = r;
        for (int j = 0; j < r.size(); j += 2)
        {
            string x = "";
            x += r[j];
            x += r[j + 1];
            int id = hash_code(x);
            de[id].x++;
            de[id].s = x;
            a[i][j] = id;
        }
    }
    sort(de, de + 256, cmp);
    for (int i = 0; i < 16; i++)
        de[i].k = uke[i];
    for (int i = 0; i < 16; i++)
        cout << de[i].s;
    cout << '\n';
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < eee[i].size() / 2; j++)
        {
            int minn = 1e9, id;
            for (int q = 0; q < 16; q++)
            {
                if (abs(a[i][j] - de[q].id) < minn)
                    id = q, minn = abs(a[i][j] - de[q].id);
            }
            cout << de[id].k;
        }
        cout << '\n';
    }
    return 0;
}
2024/12/5 22:23
加载中...