博客
关于我
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三方登录,移动端与服务端交互
    查看>>
    Redis事务深入解析和使用
    查看>>
    PHP上传文件大小限制的调整 Nginx 413 Request Entity Too Large
    查看>>
    php上传文件找不到临时文件夹
    查看>>
    PHP上传文件时保存文件原有的文件名
    查看>>
    PHP下curl用法分析
    查看>>
    php下载文件
    查看>>
    php与web服务器关系
    查看>>
    redis事务操作
    查看>>
    php中0,空,null和false的区别
    查看>>
    PHP中array_merge和array相加的区别分析
    查看>>
    PHP中Closure::bindTo的用法分析
    查看>>
    php中curl得使用
    查看>>
    PHP中curl特性
    查看>>
    PHP中date时间不对
    查看>>
    PHP中dirname(__FILE__)的意思
    查看>>
    PHP中extract()函数的妙用
    查看>>
    PHP中fileinfo的作用以及怎么开启fileinfo
    查看>>
    PHP中file_get_contents如何带上cookies
    查看>>
    PHP中header的作用
    查看>>