首页 > 其他分享 >牛客小白月赛54 C School(思维)

牛客小白月赛54 C School(思维)

时间:2022-08-13 12:56:46浏览次数:83  
标签:校卡 School end v1 54 LL begin 牛客 v2

https://ac.nowcoder.com/acm/contest/38457/C

爆时版本,想不明白

D 国的时间制度很奇怪,一天有 h 小时,一小时有 m 分。

位于 D 国的校长给学生发放了校卡。

这种校卡具有通话功能,但是在某些时间段,校卡是不能通话的。

共有 n 个不能通话时间段,第 i 段从 ai 时 bi分 到 ci时 di 分不可通话(包含)。

同时,会有 q组询问,每次询问包含两个整数 x,y ,询问的是 x 时 y 分是否可以打电话。如果可以则输出 Yes,否则输出 No。
输入
3 24 60 2
7 0 11 15
14 20 17 35
18 50 21 10
7 1
21 11
输出
No
Yes
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int main()
{
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(0);
    LL n,h,m,q;
    cin>>n>>h>>m>>q;
    vector<LL> v1;
    vector<LL> v2;
    for(LL i=0;i<n;i++)
    {
        LL x1,y1,x2,y2;
        cin>>x1>>y1>>x2>>y2;
        v1.push_back(x1*m+y1);
        v2.push_back(x2*m+y2);
    }
    sort(v1.begin(),v1.end());
    sort(v2.begin(),v2.end());
    while(q--)
    {
        LL x,y;
        cin>>x>>y;
        LL flag=x*m+y;
        LL l=lower_bound(v1.begin(),v1.end(),flag)-v1.begin();
        LL r=lower_bound(v2.begin(),v2.end(),flag)-v2.begin();
        if(l==r) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}

标签:校卡,School,end,v1,54,LL,begin,牛客,v2
From: https://www.cnblogs.com/Vivian-0918/p/16582810.html

相关文章