题解

327 条题解

  • 0
    @ 2015-10-30 23:05:22

    数据太弱……
    #include<iostream>
    #include<cstdio>
    #include<algorithm>
    using namespace std;
    int tree[10010]={0};
    int main() {
    int l,m,t1,t2;
    cin >> l >> m;
    for (int i=1; i<=m; i++) {
    cin >> t1 >> t2;
    for (int j=t1; j<=t2; j++)
    if (!tree[j]) {
    tree[j]=1;
    l--;
    }
    }
    cout << ++l;
    return 0;
    }

  • 0
    @ 2015-09-27 09:51:19

    #include <cstdio>
    #include <cstring>
    #include <iostream>
    #include <algorithm>
    #include <cmath>
    #include <ctime>
    using namespace std;
    int x[1000],y[1000];
    bool a[10000];
    int main()
    {
    int l,m,g=0,i,j;
    cin>>l>>m;
    for(i=0; i<m; i++)
    cin>>x[i]>>y[i];
    for(i=0; i<=l; i++)
    a[i]=1;
    for(i=0; i<m; i++)
    for(j=x[i]; j<=y[i]; j++)
    a[j]=0;
    for(i=0; i<=l; i++)
    if(a[i]==1)
    g++;
    cout<<g<<endl;
    return 0;
    }

  • 0
    @ 2015-09-16 18:50:09

    AC 10题留念lalalalalalalalllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦啦

  • 0
    @ 2015-08-20 18:38:05

    数据弱,直接暴力……
    #include <cstdio>
    #include <cstring>
    int main() {
    int start[100],end[100];
    bool covered[10001];
    int L,M;scanf("%d%d",&L,&M);
    for(int i=0;i<M;i++) scanf("%d%d",&start[i],&end[i]);
    memset(covered,false,sizeof(covered));
    for(int i=0;i<M;i++)
    for(int j=start[i];j<=end[i];j++)
    covered[j]=true;
    int ans=0;
    for(int i=0;i<=L;i++) if(!covered[i]) ans++;
    printf("%d",ans);
    return 0;
    }

  • 0
    @ 2015-08-12 20:02:52

    var l,i,j,jsq:0..10000;
    m:0..100;
    a:array[1..100,1..2] of 0..100000;
    tree:array[0..10000]of 0..1;
    begin
    read(l);
    read(m);
    for i:=1 to m do
    read(a[i,1],a[i,2]);
    for i:=0 to l do
    tree[i]:=1;
    for i:=1 to m do
    for j:=a[i,1] to a[i,2] do
    tree[j]:=0;
    for i:=0 to l do
    if tree[i]=1 then inc(jsq);
    write(jsq);
    end.

  • 0
    @ 2015-08-03 15:18:08

    #include<cstdio>
    #include<iostream>
    #include<cstring>
    using namespace std;
    int v[51000];
    int main()
    {
    int n,m,x,y,t,ans=0;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
    scanf("%d%d",&x,&y);
    while(x<=y)
    {
    v[x++]=1;
    }
    }
    for(int i=0;i<=n;i++)
    {
    if(v[i]!=1)
    {
    ans++;
    }
    }
    printf("%d\n",ans);
    return 0;
    }

  • 0
    @ 2015-07-27 13:23:40

    新技能get

  • 0
    @ 2015-07-26 13:19:52

    #include<cstdio>
    #include<cstring>
    #include<iostream>
    #include<algorithm>
    using namespace std;

    int main()
    {
    int l, m;
    int z[210];
    bool t[10010];
    int tot = 0;
    memset(t,1,sizeof(t));
    scanf("%d",&l);
    scanf("%d",&m);
    for(int i = 0; i < 2 * m; i++)
    scanf("%d",&z[i]);
    for(int i = 0; i < m; i++)
    for(int j = z[2 * i ]; j <= z[2 * i + 1]; j++)
    t[j] = 0;
    for(int i = 0; i <= l; i++)
    if(t[i] == 1) tot++;
    printf("%d",tot);
    return 0;

    }

  • 0
    @ 2015-07-22 17:36:30

    求大神看看为什么错啦var
    a:array[1..1000]of longint;
    i,l,m,n1,n2,j,jieguo:longint;
    begin
    read(l,m);
    readln;
    for i:= 1 to l+1 do
    a[i]:=1;
    for i:= 1 to m do
    begin
    read(n1,n2);
    for j:=n1 to n2 do
    a[j]:=0;
    end;
    jieguo:=0;
    for i:= 1 to l+1 do
    begin
    if a[i]=1 then
    inc(jieguo);
    end;
    write(jieguo);

    end.

    • @ 2016-08-05 09:01:53

      数组大小应该是[1..1001]

  • 0
    @ 2015-07-15 10:58:18

    include<stdio.h> include<iostream>
    using namespace std;
    int x[10005],n,ans,m;
    int main()
    {
    int i;
    int a,b;
    scanf("%d %d",&m,&n);
    for(i=0;i<n;i++)
    {
    scanf("%d %d",&a,&b);
    while(a<=b)
    x[a++]=1;
    }
    for(i=0;i<=m;i++)
    if(x[i]==0)ans++;
    printf("%d\n",ans);
    return 0;
    }
    大神的标准答案......

  • 0
    @ 2015-06-27 19:23:20

    P1103校门外的树Accepted
    记录信息
    评测状态 Accepted
    题目 P1103 校门外的树
    递交时间 2015-06-27 19:22:46
    代码语言 C++
    评测机 VijosEx
    消耗时间 30 ms
    消耗内存 320 KiB
    评测时间 2015-06-27 19:22:48
    评测结果
    编译成功

    测试数据 #0: Accepted, time = 0 ms, mem = 320 KiB, score = 10
    测试数据 #1: Accepted, time = 15 ms, mem = 320 KiB, score = 10
    测试数据 #2: Accepted, time = 0 ms, mem = 320 KiB, score = 10
    测试数据 #3: Accepted, time = 0 ms, mem = 316 KiB, score = 10
    测试数据 #4: Accepted, time = 0 ms, mem = 320 KiB, score = 10
    测试数据 #5: Accepted, time = 0 ms, mem = 316 KiB, score = 10
    测试数据 #6: Accepted, time = 0 ms, mem = 320 KiB, score = 10
    测试数据 #7: Accepted, time = 15 ms, mem = 320 KiB, score = 10
    测试数据 #8: Accepted, time = 0 ms, mem = 320 KiB, score = 10
    测试数据 #9: Accepted, time = 0 ms, mem = 316 KiB, score = 10
    Accepted, time = 30 ms, mem = 320 KiB, score = 100
    代码
    #include<stdio.h>
    #include<iostream>
    using namespace std;
    int x[10005],n,ans,m;
    int main()
    {
    int i;
    int a,b;
    scanf("%d %d",&m,&n);
    for(i=0;i<n;i++)
    {
    scanf("%d %d",&a,&b);
    while(a<=b)
    x[a++]=1;
    }
    for(i=0;i<=m;i++)
    if(x[i]==0)ans++;
    printf("%d\n",ans);
    return 0;
    }

  • 0
    @ 2015-05-01 20:13:57

    /*************************************************************************
    > File Name: 1103.cpp
    > Author: Netcan
    > Blog: http://www.netcan.xyz
    > Mail: 1469709759@qq.com
    > Created Time: Fri 01 May 2015 19:58:28 CST
    ************************************************************************/

    #include <iostream>
    #include <vector>
    #include <string>
    #include <queue>
    #include <algorithm>
    #include <cmath>
    #include <ctime>
    #include <cstdio>
    #include <sstream>
    #include <deque>
    #include <functional>
    #include <iterator>
    #include <list>
    #include <map>
    #include <memory>
    #include <stack>
    #include <set>
    #include <numeric>
    #include <utility>
    using namespace std;

    int main()
    {
    static bool Tree[10005];
    int L,M;
    while(scanf("%d%d", &L, &M) == 2) {
    for(int i=0; i<=L; ++i)
    Tree[i] = true;
    int a,b;
    for(int i=0; i<M; ++i) {
    scanf("%d%d", &a, &b);
    for(int j=a; j<=b; ++j)
    if(Tree[j])
    Tree[j] = false;
    }
    int sum=0;
    for(int i=0; i<=L; ++i)
    if(Tree[i])
    ++sum;
    printf("%d\n", sum);
    }

    return 0;
    }

  • 0
    @ 2015-05-01 20:12:47

    ###Block Code
    /*************************************************************************
    > File Name: 1103.cpp
    > Author: Netcan
    > Blog: http://www.netcan.xyz
    > Mail: 1469709759@qq.com
    > Created Time: Fri 01 May 2015 19:58:28 CST
    ************************************************************************/

    #include <iostream>
    #include <vector>
    #include <string>
    #include <queue>
    #include <algorithm>
    #include <cmath>
    #include <ctime>
    #include <cstdio>
    #include <sstream>
    #include <deque>
    #include <functional>
    #include <iterator>
    #include <list>
    #include <map>
    #include <memory>
    #include <stack>
    #include <set>
    #include <numeric>
    #include <utility>
    using namespace std;

    int main()
    {
    static bool Tree[10005];
    int L,M;
    while(scanf("%d%d", &L, &M) == 2) {
    for(int i=0; i<=L; ++i)
    Tree[i] = true;
    int a,b;
    for(int i=0; i<M; ++i) {
    scanf("%d%d", &a, &b);
    for(int j=a; j<=b; ++j)
    if(Tree[j])
    Tree[j] = false;
    }
    int sum=0;
    for(int i=0; i<=L; ++i)
    if(Tree[i])
    ++sum;
    printf("%d\n", sum);
    }

    return 0;
    }

  • 0
    @ 2015-05-01 20:11:56

    /*************************************************************************
    > File Name: 1103.cpp
    > Author: Netcan
    > Blog: http://www.netcan.xyz
    > Mail: 1469709759@qq.com
    > Created Time: Fri 01 May 2015 19:58:28 CST
    ************************************************************************/

    #include <iostream>
    #include <vector>
    #include <string>
    #include <queue>
    #include <algorithm>
    #include <cmath>
    #include <ctime>
    #include <cstdio>
    #include <sstream>
    #include <deque>
    #include <functional>
    #include <iterator>
    #include <list>
    #include <map>
    #include <memory>
    #include <stack>
    #include <set>
    #include <numeric>
    #include <utility>
    using namespace std;

    int main()
    {
    static bool Tree[10005];
    int L,M;
    while(scanf("%d%d", &L, &M) == 2) {
    for(int i=0; i<=L; ++i)
    Tree[i] = true;
    int a,b;
    for(int i=0; i<M; ++i) {
    scanf("%d%d", &a, &b);
    for(int j=a; j<=b; ++j)
    if(Tree[j])
    Tree[j] = false;
    }
    int sum=0;
    for(int i=0; i<=L; ++i)
    if(Tree[i])
    ++sum;
    printf("%d\n", sum);
    }

    return 0;
    }

  • 0
    @ 2015-04-22 19:16:02

    #include<iostream>
    #include<cstdlib>
    #include<cmath>
    using namespace std;
    int main()
    {
    int f[10001];
    int a,b,L,M,s=0,i;
    cin>>L>>M;
    for(i=0;i<=L;++i) f[i]=1;
    for(i=1;i<=M;++i)
    {
    cin>>a>>b;
    for(int j=a;j<=b;++j) f[j]=0;
    }
    for(i=0;i<=L;++i) s+=f[i];
    cout<<s;

    return 0;
    }

  • 0
    @ 2015-03-07 09:02:33

    var
    a:array[1..10000] of longint;
    l,m,i,n,b,j,k:integer;
    begin
    read(l,m);
    readln;
    for i:=1 to l+1 do
    a[i]:=0;
    for i:=1 to m do
    begin
    read(n,b);
    readln;
    for j:=n+1 to b+1 do
    a[j]:=a[j]+1;
    end;
    k:=0;
    for i:=1 to l+1 do
    if a[i]=0 then
    k:=k+1;
    write(k);
    end.

  • 0
    @ 2015-03-07 09:02:29

    var
    a:array[1..10000] of longint;
    l,m,i,n,b,j,k:integer;
    begin
    read(l,m);
    readln;
    for i:=1 to l+1 do
    a[i]:=0;
    for i:=1 to m do
    begin
    read(n,b);
    readln;
    for j:=n+1 to b+1 do
    a[j]:=a[j]+1;
    end;
    k:=0;
    for i:=1 to l+1 do
    if a[i]=0 then
    k:=k+1;
    write(k);
    end.

  • 0
    @ 2015-03-07 09:02:24

    var
    a:array[1..10000] of longint;
    l,m,i,n,b,j,k:integer;
    begin
    read(l,m);
    readln;
    for i:=1 to l+1 do
    a[i]:=0;
    for i:=1 to m do
    begin
    read(n,b);
    readln;
    for j:=n+1 to b+1 do
    a[j]:=a[j]+1;
    end;
    k:=0;
    for i:=1 to l+1 do
    if a[i]=0 then
    k:=k+1;
    write(k);
    end.

  • 0
    @ 2015-01-25 21:12:47

    var
    a:array[1..10000] of longint;
    l,m,i,n,b,j,k:integer;
    begin
    read(l,m);
    readln;
    for i:=1 to l+1 do
    a[i]:=0;
    for i:=1 to m do
    begin
    read(n,b);
    readln;
    for j:=n+1 to b+1 do
    a[j]:=a[j]+1;
    end;
    k:=0;
    for i:=1 to l+1 do
    if a[i]=0 then
    k:=k+1;
    write(k);
    end.

  • 0
    @ 2015-01-13 15:22:46

    #include <iostream>
    #include <algorithm>
    #include <vector>
    using namespace std;

    int main(){
    int n, m;

    cin >> n;
    vector<char> trees(n + 1, 0);
    vector<char>::iterator bitr = trees.begin();
    cin >> m;
    for(int i = 0; i < m; ++i){
    int a, b;
    cin >> a >> b;
    fill(bitr + a, bitr + b + 1, 1);
    }
    cout << count(bitr, trees.end(), 0) << endl;

    return 0;
    }

信息

ID
1103
难度
4
分类
模拟 点击显示
标签
递交数
14316
已通过
6534
通过率
46%
被复制
54
上传者