Tira_misu @ 2024-12-03 20:25:28
#include<stdio.h>
int main()
{
int l,m,i,ct = 0;
scanf("%d %d",&l,&m);
int b[l+1];
for(int k = 0;k<=l;k++)
{
b[k]=1;
}
int a[m][2];
for(i=0;i<m;i++)
{
scanf("%d %d",&a[i][0],&a[i][1]);
}
for(int j = 0;j<=l;j++)
{
for(int o = 0;o<=m;o++)
{
if(a[o][0]<=j&&j<=a[o][1])
b[j]=0;
}
}
for(int p = 0;p<=l;p++)
{
ct+=b[p];
}
printf("%d",ct);
return 0;
}
by pies_0x @ 2024-12-03 20:48:57
@Tira_misu 拍出了 hack,正在调
inout
5 3
1 1
4 5
3 4
ans
2
by pies_0x @ 2024-12-03 20:52:14
@Tira_misu 过了,你的第 <=
改成 <
#include<stdio.h>
int main()
{
int l,m,i,ct = 0;
scanf("%d %d",&l,&m);
int b[l+1];
for(int k = 0;k<=l;k++)
{
b[k]=1;
}
int a[m][2];
for(i=0;i<m;i++)
{
scanf("%d %d",&a[i][0],&a[i][1]);
}
for(int j = 0;j<=l;j++)
{
for(int o = 0;o<m;o++)
{
if(a[o][0]<=j&&j<=a[o][1])
b[j]=0;
}
}
for(int p = 0;p<=l;p++)
{
ct+=b[p];
}
printf("%d",ct);
return 0;
}
by Tira_misu @ 2024-12-10 09:24:36
@pies_0x 太感谢大佬了呜呜呜