提出 #64593434
ソースコード 拡げる
#include<bits/stdc++.h>
#define FastIO
#ifdef FastIO
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<23,stdin)),*p2=0,*p1++)
#endif //#ifdef FastIO
using namespace std;int n,m,k;
namespace IO{char buf[8888888],*p1=buf,*p2=buf,ibuf;
int rd(int x=0,int f=1){for(;!isdigit(ibuf);ibuf=getchar())ibuf=='-'&&(f=-1);for(;isdigit(ibuf);ibuf=getchar())x=(x<<1)+(x<<3)+(ibuf^48);return x*f;}
int rds(char*s,int n=0){for(;!isgraph(ibuf);ibuf=getchar());for(;isgraph(ibuf);ibuf=getchar())s[n++]=ibuf;return s[n]=0,n;}
}using IO::rd;using IO::rds;//namespace IO
#define fio(s) (freopen(s".in","r",stdin),freopen(s".out","w",stdout))
int a[1000100];
char s[1000100];
int lc[2000200],rc[2000200],val[2000200],tot=1;
#define SEG int&L=lc[x],&R=rc[x],M=l+r>>1
#define PSU val[x]=max(val[L],val[R])
int qx,ql,qr,qv;
void upd(int&x,int l=1,int r=m+1)
{
if(!x)x=tot++,lc[x]=rc[x]=val[x]=0;
if(l==r-1)return val[x]=qv,void();
SEG;
if(qx<M)upd(L,l,M);
else upd(R,M,r);
PSU;
}
int qry(int x,int l=1,int r=m+1)
{
if(ql<=l&&r<=qr)return val[x];
SEG;
int res=0;
if(ql<M)res=qry(L,l,M);
if(qr>M)res=max(res,qry(R,M,r));
return res;
}
int l[200020],r[200020],p[200020];
int t[200020];
int f[200020];
int st[20][200020];
void cdq1(int l,int r)
{
if(l==r-1)return;
int m=l+r>>1;
cdq1(l,m);
cdq1(m,r);
tot=1;int rt=0;
int p1=l,p2=m,pt=l;
while(p1<m||p2<r)
{
if(p1==m)
{
int i=p[p2];
ql=::l[i];
qr=::r[i];
f[i]=max(f[i],qry(rt));
t[pt++]=p[p2++];
}
else if(p2==r)
{
int i=p[p1];
qx=::l[i];
qv=i;
upd(rt);
t[pt++]=p[p1++];
}
else if(::r[p[p1]]>=::r[p[p2]])
{
int i=p[p1];
qx=::l[i];
qv=i;
upd(rt);
t[pt++]=p[p1++];
}
else
{
int i=p[p2];
ql=::l[i];
qr=::r[i];
f[i]=max(f[i],qry(rt));
t[pt++]=p[p2++];
}
}
for(int i=l;i<r;i++)p[i]=t[i];
}
void cdq2(int l,int r)
{
if(l==r-1)return;
int m=l+r>>1;
cdq2(l,m);
cdq2(m,r);
tot=1;int rt=0;
int p1=l,p2=m,pt=l;
while(p1<m||p2<r)
{
if(p1==m)
{
int i=p[p2];
ql=::l[i]+1;
qr=::r[i]+1;
f[i]=max(f[i],qry(rt));
t[pt++]=p[p2++];
}
else if(p2==r)
{
int i=p[p1];
qx=::r[i];
qv=i;
upd(rt);
t[pt++]=p[p1++];
}
else if(::r[p[p1]]>=::r[p[p2]])
{
int i=p[p1];
qx=::r[i];
qv=i;
upd(rt);
t[pt++]=p[p1++];
}
else
{
int i=p[p2];
ql=::l[i]+1;
qr=::r[i]+1;
f[i]=max(f[i],qry(rt));
t[pt++]=p[p2++];
}
}
for(int i=l;i<r;i++)p[i]=t[i];
}
signed main(){int Tst=1;
//Tst=rd();
while(Tst--){
m=rd();n=rd();int q=rd();
for(int i=1;i<=n;i++)l[i]=rd(),r[i]=rd(),p[i]=i;
cdq1(1,n+1);
for(int i=1;i<=n;i++)p[i]=i;
cdq2(1,n+1);
for(int i=1;i<=n;i++)st[0][i]=f[i];
for(int i=1;i<20;i++)for(int j=1;j+(1<<i)<=n+1;j++)st[i][j]=max(st[i-1][j],st[i-1][j+(1<<i-1)]);
while(q--)
{
int L=rd(),R=rd();
int w=__lg(R-L+1);
int res=max(st[w][L],st[w][R+1-(1<<w)]);
if(res<L)puts("Yes");
else puts("No");
}
//newline!
}return 0;}
提出情報
| 提出日時 |
|
| 問題 |
D - Roadway |
| ユーザ |
while_1 |
| 言語 |
C++ 20 (gcc 12.2) |
| 得点 |
0 |
| コード長 |
3078 Byte |
| 結果 |
WA |
| 実行時間 |
1122 ms |
| メモリ |
29396 KiB |
コンパイルエラー
Main.cpp: In function ‘void upd(int&, int, int)’:
Main.cpp:16:37: warning: suggest parentheses around ‘+’ inside ‘>>’ [-Wparentheses]
16 | #define SEG int&L=lc[x],&R=rc[x],M=l+r>>1
| ~^~
Main.cpp:23:9: note: in expansion of macro ‘SEG’
23 | SEG;
| ^~~
Main.cpp: In function ‘int qry(int, int, int)’:
Main.cpp:16:37: warning: suggest parentheses around ‘+’ inside ‘>>’ [-Wparentheses]
16 | #define SEG int&L=lc[x],&R=rc[x],M=l+r>>1
| ~^~
Main.cpp:31:9: note: in expansion of macro ‘SEG’
31 | SEG;
| ^~~
Main.cpp: In function ‘void cdq1(int, int)’:
Main.cpp:44:16: warning: suggest parentheses around ‘+’ inside ‘>>’ [-Wparentheses]
44 | int m=l+r>>1;
| ~^~
Main.cpp: In function ‘void cdq2(int, int)’:
Main.cpp:89:16: warning: suggest parentheses around ‘+’ inside ‘>>’ [-Wparentheses]
89 | int m=l+r>>1;
| ~^~
Main.cpp: In function ‘int main()’:
Main.cpp:142:99: warning: suggest parentheses around ‘-’ inside ‘<<’ [-Wparentheses]
142 | for(int i=1;i<20;i++)for(int j=1;j+(1<<i)<=n+1;j++)st[i][j]=max(st[i-1][j],st[i-1][j+(1<<i-1)]);
| ~^~
ジャッジ結果
| セット名 |
Sample |
All |
| 得点 / 配点 |
0 / 0 |
0 / 900 |
| 結果 |
|
|
| セット名 |
テストケース |
| Sample |
00_sample_00.txt, 00_sample_01.txt |
| All |
00_sample_00.txt, 00_sample_01.txt, 01_test_00.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt, 01_test_14.txt, 01_test_15.txt, 01_test_16.txt, 01_test_17.txt, 01_test_18.txt, 01_test_19.txt, 01_test_20.txt, 01_test_21.txt, 01_test_22.txt, 01_test_23.txt, 01_test_24.txt, 01_test_25.txt, 01_test_26.txt, 01_test_27.txt, 01_test_28.txt |
| ケース名 |
結果 |
実行時間 |
メモリ |
| 00_sample_00.txt |
AC |
1 ms |
3560 KiB |
| 00_sample_01.txt |
AC |
1 ms |
3620 KiB |
| 01_test_00.txt |
WA |
1121 ms |
29324 KiB |
| 01_test_01.txt |
WA |
911 ms |
26660 KiB |
| 01_test_02.txt |
WA |
1072 ms |
28604 KiB |
| 01_test_03.txt |
WA |
1078 ms |
28732 KiB |
| 01_test_04.txt |
WA |
986 ms |
27428 KiB |
| 01_test_05.txt |
WA |
1080 ms |
28644 KiB |
| 01_test_06.txt |
WA |
955 ms |
27088 KiB |
| 01_test_07.txt |
WA |
893 ms |
26516 KiB |
| 01_test_08.txt |
WA |
920 ms |
26780 KiB |
| 01_test_09.txt |
WA |
1053 ms |
28432 KiB |
| 01_test_10.txt |
WA |
759 ms |
26260 KiB |
| 01_test_11.txt |
WA |
970 ms |
29008 KiB |
| 01_test_12.txt |
WA |
941 ms |
28560 KiB |
| 01_test_13.txt |
WA |
613 ms |
25048 KiB |
| 01_test_14.txt |
WA |
873 ms |
27680 KiB |
| 01_test_15.txt |
WA |
943 ms |
28584 KiB |
| 01_test_16.txt |
WA |
910 ms |
28200 KiB |
| 01_test_17.txt |
WA |
896 ms |
27984 KiB |
| 01_test_18.txt |
WA |
978 ms |
29396 KiB |
| 01_test_19.txt |
WA |
933 ms |
28560 KiB |
| 01_test_20.txt |
WA |
7 ms |
4336 KiB |
| 01_test_21.txt |
WA |
7 ms |
4204 KiB |
| 01_test_22.txt |
WA |
8 ms |
4484 KiB |
| 01_test_23.txt |
WA |
12 ms |
5456 KiB |
| 01_test_24.txt |
WA |
489 ms |
24408 KiB |
| 01_test_25.txt |
WA |
544 ms |
24608 KiB |
| 01_test_26.txt |
AC |
1122 ms |
27984 KiB |
| 01_test_27.txt |
AC |
536 ms |
21704 KiB |
| 01_test_28.txt |
AC |
850 ms |
25460 KiB |