327 条题解
-
0luochengyi LV 8 @ 2009-04-04 13:26:28
水题,用数组就足够
program lt;
var a:array[0..10000] of byte;
c,m,i,x,y,co,j:integer;
begin
readln(c,m); for i:=0 to c do a[i]:=1;
for i:=1 to m do
begin
readln(x,y);
for j:=x to y do
a[j]:=0;
end;
for i:=0 to c do
if a[i]=1 then co:=co+1;
writeln(co);
end. -
02009-03-28 21:26:41@
编译通过...
├ 测试数据 01:答案正确... 0ms
├ 测试数据 02:答案正确... 0ms
├ 测试数据 03:答案正确... 0ms
├ 测试数据 04:答案正确... 0ms
├ 测试数据 05:答案正确... 0ms
├ 测试数据 06:答案正确... 0ms
├ 测试数据 07:答案正确... 0ms
├ 测试数据 08:答案正确... 0ms
├ 测试数据 09:答案正确... 0ms
├ 测试数据 10:答案正确... 0ms
---|---|---|---|---|---|---|---|-
Accepted 有效得分:100 有效耗时:0ms
我无语了~~~ -
02009-03-28 12:02:49@
用线段树秒杀....
-
02009-03-28 11:07:29@
#include
using namespace std;
int main()
{
bool a[10000];
int l,m,be[10000],en[10000],x=0;
cin>>l>>m;
for(int i=0;i>be[i];
cin>>en[i];
}
for(int i=1;i -
02009-03-26 21:36:27@
埃,算错了一步,AC率直掉.......
-
02009-03-13 19:15:07@
var
a,b,s,m,n,i,j:integer;
arr:array[0..10000] of integer;
begin
read(a,b);readln;
for i:=0 to a do arr[i]:=1;
for i:=1 to b do
begin
read(m,n);readln;
for j:=m to n do arr[j]:=0;
end;
s:=0;
for i:=0 to a do if arr[i]=1 then s:=s+1;
write(s);
end. -
02009-03-05 00:39:23@
#include
#includetypedef struct _DISTRICT {
int start;
int end;
int bUsed;
}DISTRICT;#define MAX_DISTRICT 100
#define TRUE 1
#define FALSE 0void main()
{
int l, m;
DISTRICT dis[MAX_DISTRICT];
int start, end;
int availDistrict = 0;
int occupiedTree = 0;
int i, j, k;memset(dis, 0, sizeof(dis));
scanf("%d %d", &l, &m);
for (i = 0; i < m; i++)
{
scanf("%d %d", &start, &end);
// insert sort, order by dis[i].start
for (j = 0; j < availDistrict; j++)
{
if (start < dis[j].start)
{
k = availDistrict;
while(k > j)
{
dis[k].start = dis[k-1].start;
dis[k].end = dis[k-1].end;
k--;
}
break;
}
}
dis[j].start = start;
dis[j].end = end;
dis[j].bUsed = TRUE;
availDistrict++;
}// merge overlap district
for (i = 0; i < availDistrict - 1;)
{
for (j = i+1; j < availDistrict; j++)
{
if (dis[i].start -
02009-03-04 13:07:20@
program tree;
var
i,j,m,l,total,p:longint;
a,b,c,d:array[1..10000]of longint;
begin
readln(l,m);
for i:=1 to m do
readln(a[i],b[i]);
total:=l+1;
for i:=0 to l do
for j:=1 to m do
if (i>=a[j])and(i -
02009-02-26 20:55:29@
var s,L,m,i,j,p,q,max,t:integer;
a:array[1..100,1..2] of integer;
b:array[1..10000] of boolean;
begin
read(L);
read(m);
for i:=1 to m do
begin
read(a);
read(a);
end;
for i:=1 to m do
for j:=a to a do
b[j]:=true;
p:=1;
q:=1;
for i:=1 to m do
for j:=1 to 2 do
begin
max:=a[p,q];
if a[p,q] -
02009-02-21 13:52:51@
坚决支持用布尔型,水啊!
-
02009-01-16 16:15:41@
var n,m,i,a,b,j,s:longint;
f:array[0..10000] of boolean;
begin
read(n,m);
for i:=1 to m do
begin
read(a,b);
for j:=a to b do f[j]:=true;
end;
for i:=0 to n do if f[i]true then inc(s);
writeln(s);
end.用boolean数组记录 从a到b变成true
最后只要这个数组true就inc(s)
注意循环要从0开始 -
02009-01-15 15:00:12@
编译通过...
├ 测试数据 01:答案正确... 0ms
├ 测试数据 02:答案正确... 0ms
├ 测试数据 03:答案正确... 0ms
├ 测试数据 04:答案正确... 0ms
├ 测试数据 05:答案正确... 0ms
├ 测试数据 06:答案正确... 0ms
├ 测试数据 07:答案正确... 0ms
├ 测试数据 08:答案正确... 0ms
├ 测试数据 09:答案正确... 0ms
├ 测试数据 10:答案正确... 0ms
---|---|---|---|---|---|---|---|-
Accepted 有效得分:100 有效耗时:0ms -
02008-12-30 14:29:55@
#include
#include
int main() {
char tree[10001];
int l,m,i,a,b,n;
scanf("%d%d",&l,&m);
memset(tree,1,l+1);
for(i=0;i -
02008-12-20 08:34:09@
program tree;
var
m,l,x,i,j,k,n:integer;
a:array[1..10000] of longint;
beginn:=0;
read(l,x);
for i:=1 to x do
begin
readln(j,k);
for m:=j to k do
a[m]:=1
end;
for i:=1 to l do
if a[i]=1 then n:=n+1;
l:=l-n+1;
write(l);
end. -
02008-12-19 18:43:46@
var
a,b,s,m,n,i,j:integer;
arr:array[0..10000] of integer;
begin
read(a,b);readln;
for i:=0 to a do arr[i]:=1;
for i:=1 to b do
begin
read(m,n);readln;
for j:=m to n do arr[j]:=0;
end;
s:=0;
for i:=0 to a do if arr[i]=1 then s:=s+1;
write(s);
end. -
02008-12-03 13:42:00@
编译通过...
├ 测试数据 01:答案正确... 0ms
├ 测试数据 02:答案正确... 0ms
├ 测试数据 03:答案正确... 0ms
├ 测试数据 04:答案正确... 0ms
├ 测试数据 05:答案正确... 0ms
├ 测试数据 06:答案正确... 0ms
├ 测试数据 07:答案正确... 0ms
├ 测试数据 08:答案正确... 0ms
├ 测试数据 09:答案正确... 0ms
├ 测试数据 10:答案正确... 0ms
---|---|---|---|---|---|---|---|-
Accepted 有效得分:100 有效耗时:0ms减法运用,只要你认真地想想.你就会
var a,b,i,j,k:integer;
c:array[1..101,1..2]of integer;
d:array[0..10000] of integer;
begin
readln(a,b);
for i:=0 to a do d[i]:=1;
for i:=1 to b do
begin
readln(c,c);
for j:=c to c do
d[j]:=0;
end;
k:=0;
for i:=0 to a do
if d[i]=1 then k:=k+1;
writeln(k);
end. -
02008-11-29 15:31:54@
var a,b,i,j,k:integer;
c:array[1..101,1..2]of integer;
d:array[0..10000] of integer;
begin
readln(a,b);
for i:=0 to a do d[i]:=1;
for i:=1 to b do
begin
readln(c,c);
for j:=c to c do
d[j]:=0;
end;
k:=0;
for i:=0 to a do
if d[i]=1 then k:=k+1;
writeln(k);
end.
一条浑浊不清的水题 -
02008-11-28 20:56:05@
编译通过...
├ 测试数据 01:答案正确... 0ms
├ 测试数据 02:答案正确... 0ms
├ 测试数据 03:答案正确... 0ms
├ 测试数据 04:答案正确... 0ms
├ 测试数据 05:答案正确... 0ms
├ 测试数据 06:答案正确... 0ms
├ 测试数据 07:答案正确... 0ms
├ 测试数据 08:答案正确... 0ms
├ 测试数据 09:答案正确... 0ms
├ 测试数据 10:答案正确... 0ms
---|---|---|---|---|---|---|---|-
Accepted 有效得分:100 有效耗时:0ms -
02008-11-22 22:37:04@
program p1103;
var
x,y:array[1..101] of longint;
i,l,m,start,over:longint;
procedure q_sort(l,r:longint);
var
i,j,mid,t:longint;
begin
i:=l;
j:=r;
mid:=x[(l+r)div 2];
repeat
while x[i]mid do dec(j);
if ij;
if il then q_sort(l,j);
end;begin
read(l,m);
for i:=1 to m do
read(x[i],y[i]);
q_sort(1,m);
start:=x[1];
over:=y[1];
x[m+1]:=maxlongint; //懒得再添加判断了~~~
l:=l+1; //不要忘了点0!!
for i:=2 to m+1 do
if x[i]over
then
over:=y[i];
end //这个begin end一定要打!!!否则else就跟到第二个then上了
else
begin
l:=l-(over-start+1);
start:=x[i];
over:=y[i];
end;
writeln(l);
end.线段树的做法O(n log n) 对大数据比较有用
至于这种暴弱的数据 直接54 -
02008-11-13 16:06:37@
program tree;
var l,m,i,j,n:integer;
var a:array[1..10000,1..10000];
b:array[1..500];
begin
readln(l,m);
fillchar(a,size(a),0);
for i:=1 to m do
begin
readln(a,a);
for j:=a to a do
b[j]:=1;
end;for i:=1 to 500 do
if b[i]=0 then inc(n);
end.