博客
关于我
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模拟发送GET和POST请求
    查看>>
    RabbitMQ - 以 MQ 为例,手写一个 RPC 框架 demo
    查看>>
    php模板引擎smarty
    查看>>
    php正则表达式模式
    查看>>
    php正则表达式的特殊字符含义
    查看>>
    PHP正则表达式获取武汉市的实时pm2.5数据并邮件发送phpmailer
    查看>>
    RabbitMQ + JMeter组合,优化你的中间件处理方式!
    查看>>
    PHP水仙花问题解法之一
    查看>>
    php没有解析是怎么回事,linux下php文件没有被剖析怎么办?_后端开发
    查看>>
    php注册页面实现注册后跳转页面
    查看>>
    PHP消息队列的实现方式与详解,值得一看
    查看>>
    PHP混合Go协程并发
    查看>>
    php源码中如何添加滚动公告,给WordPress网站添加滚动公告的方法
    查看>>
    PHP源码安装后如何新增模块
    查看>>
    php源码详细安装步骤,linux下php源码安装步骤
    查看>>
    php漏洞tips
    查看>>
    php版Zencoding之 phpstorm
    查看>>
    PHP版本升级5.4手记
    查看>>
    php版本升级总结
    查看>>
    php版本微信公众号开发
    查看>>