博客
关于我
BZOJ 5443 [Ceoi2018]Lottery
阅读量:268 次
发布时间:2019-03-01

本文共 1453 字,大约阅读时间需要 4 分钟。

???????????????????????????k_i???????????????????????????????

????

  • ?????

    • k????????????????????????
    • ??????????????k_i??????????
  • ????

    • ????????????????????????
    • ????????????????????????k????
  • ?????

    • ?????????????k????
    • ??????????????????????
  • ?????

    • ???????????????????
  • ????

    #include 
    #include
    #include
    #include
    #include
    #include
    using namespace std;struct Query { int k, j; int ans_id; Query(int k_val, int j_val) : k(k_val), j(j_val) {}};int main() { // ???? vector
    L = {0, 0, 0, 0}; vector
    Q = {0, 0}; int n, q; // ????????? // ... // ?????????? map
    > substr_dict; for (int i = 0; i <= n; ++i) { for (int j = 0; j <= n - i; ++j) { string s = s[n - i + j ...]; // ????????? int mask = 0; for (int k = 0; k < i; ++k) { if (s[k] != s[k + i]) { mask |= (1 << k); } } substr_dict[mask]++; } } // ?????? for (int q_id = 0; q_id < q; ++q_id) { Query query = Q[q_id]; // ???????????? int count = 0; for (auto& pair : substr_dict) { for (auto& other : substr_dict[pair.first]) { if (pair.second > other) continue; int diff = pair.first ^ other; if (__builtin_popcount(diff) == query.k) { count++; } } } // ???? result[q_id] = count; } // ???? for (int i = 0; i < q; ++i) { cout << result[i] << endl; } return 0;}

    ????

  • ?????

    • ?????????????????????????????
  • ??????

    • ?????????????k??????
    • ???????????????????
  • ???????

    • ????????????k???????
    • ?????????????????
  • ???????????????????????????????????????????????

    转载地址:http://abwo.baihongyu.com/

    你可能感兴趣的文章
    Python-字典
    查看>>
    python-字符串
    查看>>
    Python-将二进制遮罩转换为多边形
    查看>>
    python-文件操作
    查看>>
    PYTHON-模块 sys os random shutil-练习
    查看>>
    Python-模块与包的管理
    查看>>
    PYTHON-模块定义 搜索路径
    查看>>
    Python-爬虫工程师-面试总结
    查看>>
    Python-类与文件读取结合
    查看>>
    python-类思想-实现简单增删查改
    查看>>
    python-网络编程
    查看>>
    python写入文件出现空行
    查看>>
    PYTHON-返回给定x的多边形路径的y坐标
    查看>>
    python-进程池与线程池,协程
    查看>>
    Python-通过函数传递变量
    查看>>
    Python内置函数详解——总结篇
    查看>>
    Python.对象集合中的标识.和散列
    查看>>
    Python.硒.拖放错误“AttributeError:move_to 需要 WebElement“
    查看>>
    Python内置函数详解
    查看>>
    Python/Kivy:从一个类调用函数到另一个类并在 Python 中显示小部件
    查看>>