답안 #1009192

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1009192 2024-06-27T09:52:13 Z User0069 Curtains (NOI23_curtains) C++17
100 / 100
551 ms 53668 KB
#include<bits/stdc++.h>
#define taskname ""
#define el '\n'
#define fi first
#define sc second
#define pii pair<int, int>
#define all(v) v.begin(), v.end()
#define int ll
using namespace std;
using ll=long long;
using ull=unsigned long long;
using ld=long double;
#define Faster ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
const int maxn=1e6+3;
const int mod=1e9+7;
const int INF=1e9+1;
int n,m,q,ST[maxn*4],laz[4*maxn],ans[maxn];
struct query
{
    int l,r,i,type;
};
vector<query> v;
bool operator <(query a,query b)
{
    if(a.r==b.r) return a.type<b.type;
    else return a.r<b.r;
}
//void down(int id)
//{
//    ST[id*2]
//}
void update(int id,int cl,int cr,int l,int r,int val)
{
    if(cl>r||cr<l) return;
    if(cl>=l&&cr<=r)
    {
        ST[id]=max(ST[id],val);
        return;
    }
    ST[id*2]=max(ST[id*2],ST[id]);
    ST[id*2+1]=max(ST[id*2+1],ST[id]);
    int mid=(cl+cr)/2;
    update(2*id,cl,mid,l,r,val);
    update(2*id+1,mid+1,cr,l,r,val);
    ST[id]=min(ST[id*2],ST[id*2+1]);
}
int get(int id,int cl,int cr,int l,int r)
{
    if(cr<l||cl>r) return n+1;
    if(cl>=l&&cr<=r) return ST[id];
    int mid=(cl+cr)/2;
    ST[id*2]=max(ST[id*2],ST[id]);
    ST[id*2+1]=max(ST[id*2+1],ST[id]);
    return min(get(2*id,cl,mid,l,r),get(2*id+1,mid+1,cr,l,r));
}
void solve()
{
    cin>>n>>m>>q;
    for(int i=1;i<=m;i++)
    {
        int l,r;
        cin>>l>>r;
        v.push_back({l,r,0,1});
    }
    for(int i=1;i<=q;i++)
    {
        int l,r;
        cin>>l>>r;
        v.push_back({l,r,i,2});
    }
    sort(v.begin(),v.end());
    for(query x:v)
    {
        if(x.type==1)
        {
           update(1,1,n,x.l,x.r,x.l);
        }
        else
        {
            ans[x.i]=get(1,1,n,x.l,x.r)>=x.l;
        }
    }
    for(int i=1;i<=q;i++)
    {
        cout<<(ans[i]?"YES\n":"NO\n");
    }
}
signed main()
{
    if (fopen(taskname".INP","r"))
    {
        freopen(taskname".INP","r",stdin);
        freopen(taskname".OUT","w",stdout);
    }
    Faster
    int t=1;
//    cin>>t;
    while(t--)
    {
        solve();
    }
}

Compilation message

curtains.cpp: In function 'int main()':
curtains.cpp:93:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   93 |         freopen(taskname".INP","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
curtains.cpp:94:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   94 |         freopen(taskname".OUT","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 460 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 464 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 460 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 460 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 464 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 460 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 2 ms 732 KB Output is correct
14 Correct 3 ms 604 KB Output is correct
15 Correct 3 ms 624 KB Output is correct
16 Correct 2 ms 604 KB Output is correct
17 Correct 2 ms 732 KB Output is correct
18 Correct 2 ms 732 KB Output is correct
19 Correct 2 ms 624 KB Output is correct
20 Correct 2 ms 604 KB Output is correct
21 Correct 2 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 460 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 464 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 460 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 2 ms 732 KB Output is correct
14 Correct 3 ms 604 KB Output is correct
15 Correct 3 ms 624 KB Output is correct
16 Correct 2 ms 604 KB Output is correct
17 Correct 2 ms 732 KB Output is correct
18 Correct 2 ms 732 KB Output is correct
19 Correct 2 ms 624 KB Output is correct
20 Correct 2 ms 604 KB Output is correct
21 Correct 2 ms 604 KB Output is correct
22 Correct 199 ms 24212 KB Output is correct
23 Correct 191 ms 25388 KB Output is correct
24 Correct 256 ms 36256 KB Output is correct
25 Correct 367 ms 43080 KB Output is correct
26 Correct 177 ms 24828 KB Output is correct
27 Correct 374 ms 43868 KB Output is correct
28 Correct 339 ms 42712 KB Output is correct
29 Correct 151 ms 24472 KB Output is correct
30 Correct 117 ms 24180 KB Output is correct
31 Correct 124 ms 36784 KB Output is correct
32 Correct 310 ms 43140 KB Output is correct
33 Correct 121 ms 24488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 2 ms 604 KB Output is correct
6 Correct 1 ms 684 KB Output is correct
7 Correct 2 ms 604 KB Output is correct
8 Correct 134 ms 24340 KB Output is correct
9 Correct 127 ms 36780 KB Output is correct
10 Correct 273 ms 42300 KB Output is correct
11 Correct 110 ms 24616 KB Output is correct
12 Correct 77 ms 13492 KB Output is correct
13 Correct 79 ms 13236 KB Output is correct
14 Correct 68 ms 14520 KB Output is correct
15 Correct 64 ms 12484 KB Output is correct
16 Correct 67 ms 12836 KB Output is correct
17 Correct 68 ms 14272 KB Output is correct
18 Correct 402 ms 51528 KB Output is correct
19 Correct 402 ms 52192 KB Output is correct
20 Correct 321 ms 51892 KB Output is correct
21 Correct 337 ms 52132 KB Output is correct
22 Correct 314 ms 51560 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 460 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 464 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 460 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 2 ms 732 KB Output is correct
14 Correct 3 ms 604 KB Output is correct
15 Correct 3 ms 624 KB Output is correct
16 Correct 2 ms 604 KB Output is correct
17 Correct 2 ms 732 KB Output is correct
18 Correct 2 ms 732 KB Output is correct
19 Correct 2 ms 624 KB Output is correct
20 Correct 2 ms 604 KB Output is correct
21 Correct 2 ms 604 KB Output is correct
22 Correct 81 ms 11700 KB Output is correct
23 Correct 79 ms 12364 KB Output is correct
24 Correct 90 ms 14260 KB Output is correct
25 Correct 99 ms 13200 KB Output is correct
26 Correct 73 ms 14264 KB Output is correct
27 Correct 85 ms 13708 KB Output is correct
28 Correct 63 ms 11188 KB Output is correct
29 Correct 73 ms 12900 KB Output is correct
30 Correct 91 ms 12980 KB Output is correct
31 Correct 81 ms 14368 KB Output is correct
32 Correct 95 ms 13496 KB Output is correct
33 Correct 97 ms 13660 KB Output is correct
34 Correct 93 ms 14004 KB Output is correct
35 Correct 93 ms 12724 KB Output is correct
36 Correct 88 ms 14564 KB Output is correct
37 Correct 92 ms 14312 KB Output is correct
38 Correct 117 ms 13980 KB Output is correct
39 Correct 75 ms 12612 KB Output is correct
40 Correct 97 ms 13752 KB Output is correct
41 Correct 90 ms 14120 KB Output is correct
42 Correct 67 ms 14584 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 460 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 464 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 460 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 2 ms 732 KB Output is correct
14 Correct 3 ms 604 KB Output is correct
15 Correct 3 ms 624 KB Output is correct
16 Correct 2 ms 604 KB Output is correct
17 Correct 2 ms 732 KB Output is correct
18 Correct 2 ms 732 KB Output is correct
19 Correct 2 ms 624 KB Output is correct
20 Correct 2 ms 604 KB Output is correct
21 Correct 2 ms 604 KB Output is correct
22 Correct 199 ms 24212 KB Output is correct
23 Correct 191 ms 25388 KB Output is correct
24 Correct 256 ms 36256 KB Output is correct
25 Correct 367 ms 43080 KB Output is correct
26 Correct 177 ms 24828 KB Output is correct
27 Correct 374 ms 43868 KB Output is correct
28 Correct 339 ms 42712 KB Output is correct
29 Correct 151 ms 24472 KB Output is correct
30 Correct 117 ms 24180 KB Output is correct
31 Correct 124 ms 36784 KB Output is correct
32 Correct 310 ms 43140 KB Output is correct
33 Correct 121 ms 24488 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 2 ms 604 KB Output is correct
39 Correct 1 ms 684 KB Output is correct
40 Correct 2 ms 604 KB Output is correct
41 Correct 134 ms 24340 KB Output is correct
42 Correct 127 ms 36780 KB Output is correct
43 Correct 273 ms 42300 KB Output is correct
44 Correct 110 ms 24616 KB Output is correct
45 Correct 77 ms 13492 KB Output is correct
46 Correct 79 ms 13236 KB Output is correct
47 Correct 68 ms 14520 KB Output is correct
48 Correct 64 ms 12484 KB Output is correct
49 Correct 67 ms 12836 KB Output is correct
50 Correct 68 ms 14272 KB Output is correct
51 Correct 402 ms 51528 KB Output is correct
52 Correct 402 ms 52192 KB Output is correct
53 Correct 321 ms 51892 KB Output is correct
54 Correct 337 ms 52132 KB Output is correct
55 Correct 314 ms 51560 KB Output is correct
56 Correct 81 ms 11700 KB Output is correct
57 Correct 79 ms 12364 KB Output is correct
58 Correct 90 ms 14260 KB Output is correct
59 Correct 99 ms 13200 KB Output is correct
60 Correct 73 ms 14264 KB Output is correct
61 Correct 85 ms 13708 KB Output is correct
62 Correct 63 ms 11188 KB Output is correct
63 Correct 73 ms 12900 KB Output is correct
64 Correct 91 ms 12980 KB Output is correct
65 Correct 81 ms 14368 KB Output is correct
66 Correct 95 ms 13496 KB Output is correct
67 Correct 97 ms 13660 KB Output is correct
68 Correct 93 ms 14004 KB Output is correct
69 Correct 93 ms 12724 KB Output is correct
70 Correct 88 ms 14564 KB Output is correct
71 Correct 92 ms 14312 KB Output is correct
72 Correct 117 ms 13980 KB Output is correct
73 Correct 75 ms 12612 KB Output is correct
74 Correct 97 ms 13752 KB Output is correct
75 Correct 90 ms 14120 KB Output is correct
76 Correct 67 ms 14584 KB Output is correct
77 Correct 535 ms 53668 KB Output is correct
78 Correct 530 ms 52864 KB Output is correct
79 Correct 451 ms 53132 KB Output is correct
80 Correct 420 ms 53200 KB Output is correct
81 Correct 381 ms 53056 KB Output is correct
82 Correct 370 ms 53412 KB Output is correct
83 Correct 483 ms 52896 KB Output is correct
84 Correct 531 ms 53248 KB Output is correct
85 Correct 487 ms 52876 KB Output is correct
86 Correct 483 ms 53412 KB Output is correct
87 Correct 551 ms 52392 KB Output is correct
88 Correct 426 ms 52508 KB Output is correct