博客
关于我
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中的测地距离变换
    查看>>
    Python中的私有方法
    查看>>
    Python中的空元组是“常量“吗?
    查看>>
    Python中的类-ChatGPT4o作答
    查看>>
    Python中的类中的池
    查看>>
    python中的装饰器基础
    查看>>
    python中的负零
    查看>>
    Python中的进程通信
    查看>>
    Python中的递归有多安全?
    查看>>
    python中程序如何获取实现多行输入
    查看>>
    python中算法与数学_中国古代数学算法的Python实现
    查看>>
    python中类的实例化_python类的实例化
    查看>>
    Python中类的约束
    查看>>
    python中自定义sort 规则
    查看>>
    python中自定义错误_在现代Python中声明自定义异常的正确方法?
    查看>>
    python中获取上一个月一号的方法
    查看>>
    python中蜂窝网格边缘的坐标
    查看>>