博客
关于我
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/

    你可能感兴趣的文章
    NSDateFormatter的替代方法
    查看>>
    NSError 的使用方法
    查看>>
    NSGA-Ⅲ源代码
    查看>>
    nsis 安装脚本示例(转)
    查看>>
    NSJSON的用法(oc系统自带的解析方法)
    查看>>
    nslookup 的基本知识与命令详解
    查看>>
    NSOperation基本操作
    查看>>
    NSRange 范围
    查看>>
    NSSet集合 无序的 不能重复的
    查看>>
    NSURLSession下载和断点续传
    查看>>
    NSUserdefault读书笔记
    查看>>
    NS图绘制工具推荐
    查看>>
    NT AUTHORITY\NETWORK SERVICE 权限问题
    查看>>
    NT symbols are incorrect, please fix symbols
    查看>>
    ntelliJ IDEA 报错:找不到包或者找不到符号
    查看>>
    NTFS文件权限管理实战
    查看>>
    ntko web firefox跨浏览器插件_深度比较:2019年6个最好的跨浏览器测试工具
    查看>>
    ntko文件存取错误_苹果推送 macOS 10.15.4:iCloud 云盘文件夹共享终于来了
    查看>>
    ntp server 用法小结
    查看>>
    ntpdate 通过外网同步时间
    查看>>