博客
关于我
HDU 5480
阅读量:149 次
发布时间:2019-02-27

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

??????????????????????????????????????????????????????????????????????????????

????

  • ????:

    • ???????????????
    • ??????????????????????????
  • ?????:

    • ???????????????????????
    • row_prefix[i] ???i???????
    • col_prefix[i] ???i???????
  • ????:

    • ??????????????????????????
    • ???????????????"Yes"?????"No"?
  • ????

    #include 
    #include
    using namespace std;int main() { int T; cin >> T; for (int _t = 0; _t < T; ++_t) { int n, m, K, Q; cin >> n >> m >> K >> Q; vector
    row_exists(n + 2, 0); vector
    col_exists(m + 2, 0); for (int _k = 0; _k < K; ++_k) { int a, b; cin >> a >> b; row_exists[a] = 1; col_exists[b] = 1; } vector
    row_prefix(n + 2, 0); for (int i = 1; i <= n; ++i) { row_prefix[i] = row_prefix[i-1] + row_exists[i]; } vector
    col_prefix(m + 2, 0); for (int i = 1; i <= m; ++i) { col_prefix[i] = col_prefix[i-1] + col_exists[i]; } for (int _q = 0; _q < Q; ++_q) { int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; bool has_row = (row_prefix[x2] - row_prefix[x1-1]) > 0; bool has_col = (col_prefix[y2] - col_prefix[y1-1]) > 0; if (has_row || has_col) { cout << "Yes"; } else { cout << "No"; } } } return 0;}

    ????

  • ????:

    • ????????T?
    • ???????????n, m, K, Q?
    • ???????row_exists?col_exists????????
  • ??????:

    • ????????????????????1?
  • ???????:

    • ??row_prefix?col_prefix?????????????????
  • ????:

    • ??????????????????????
    • ?????????????
  • ?????????????????????????????O(1)????????????

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

    你可能感兴趣的文章
    php多条件筛选功能的实现
    查看>>
    php多线程
    查看>>
    PHP大数组循环-避免产生Notice或者是Warning
    查看>>
    PHP大数组过滤元素、修改元素性能分析
    查看>>
    PHP大文件切片下载代码
    查看>>
    PHP如何下载远程文件到指定目录
    查看>>
    php如何优化压缩的图片
    查看>>
    php如何做表格,新手怎么制作表格
    查看>>
    RabbitMQ高级特性
    查看>>
    php如何定义的数位置,php如何实现不借助IDE快速定位行数或者方法定义的文件和位置...
    查看>>
    RabbitMQ集群 - 普通集群搭建、宕机情况
    查看>>
    php如何正确的获得文件的后缀名
    查看>>
    PHP如何生成唯一的数字ID
    查看>>
    PHP如何获取当前页面的最后修改时间
    查看>>
    PHP如何读取json数据
    查看>>
    PHP字符串
    查看>>
    PHP字符串递增
    查看>>
    php学习之基础语法
    查看>>
    RabbitMQ集群 - 仲裁队列、Raft协议(最详细的选举流程)
    查看>>
    PHP学习总结(11)——PHP入门篇之WAMPServer多站点配置
    查看>>