题解

60 条题解

  • 0
    @ 2015-02-13 18:15:48

    测试数据 #0: Accepted, time = 0 ms, mem = 888 KiB, score = 10
    测试数据 #1: Accepted, time = 15 ms, mem = 888 KiB, score = 10
    测试数据 #2: Accepted, time = 0 ms, mem = 888 KiB, score = 10
    测试数据 #3: Accepted, time = 0 ms, mem = 888 KiB, score = 10
    测试数据 #4: Accepted, time = 0 ms, mem = 892 KiB, score = 10
    测试数据 #5: Accepted, time = 0 ms, mem = 888 KiB, score = 10
    测试数据 #6: Accepted, time = 15 ms, mem = 888 KiB, score = 10
    测试数据 #7: Accepted, time = 15 ms, mem = 888 KiB, score = 10
    测试数据 #8: Accepted, time = 15 ms, mem = 888 KiB, score = 10
    测试数据 #9: Accepted, time = 15 ms, mem = 884 KiB, score = 10
    Accepted, time = 75 ms, mem = 892 KiB, score = 100
    代码
    type aa=record
    a,b,g,k:longint;
    end;
    var
    x,y,i,n:longint;
    kk:array[0..10000]of aa;

    begin

    readln(n);
    for i:=1 to n do readln(kk[i].a,kk[i].b,kk[i].g,kk[i].k);
    readln(x,y);
    for i:=n downto 1 do
    begin
    if (x>=kk[i].a) and (y>=kk[i].b) and (x<=kk[i].a+kk[i].g-1) and (y<=kk[i].b+kk[i].k-1) then begin writeln(i);readln; halt; end;
    end;

    writeln('-1');
    readln;

    end.

  • 0
    @ 2015-02-05 12:19:36

    模拟。数组从后往前扫,找到直接输出就行。

    Pascal Code

    var
    a,b,g,k:array[1..10000] of longint;
    n,x,y,i:longint;
    function iscover(a,b,g,k:longint):boolean; //判断是否覆盖的函数
    begin
    if x<a then exit(false);
    if y<b then exit(false);
    if x>a+g then exit(false);
    if y>b+k then exit(false);
    exit(true);
    end;
    begin
    read(n);
    for i:=1 to n do
    readln(a[i],b[i],g[i],k[i]);
    readln(x,y);
    for i:=n downto 1 do
    if iscover(a[i],b[i],g[i],k[i])
    then begin
    writeln(i);
    halt;
    end;
    writeln(-1);
    end.

  • 0
    @ 2014-10-15 17:52:30

    编译成功

    测试数据 #0: Accepted, time = 15 ms, mem = 980 KiB, score = 10

    测试数据 #1: Accepted, time = 0 ms, mem = 984 KiB, score = 10

    测试数据 #2: Accepted, time = 0 ms, mem = 976 KiB, score = 10

    测试数据 #3: Accepted, time = 0 ms, mem = 980 KiB, score = 10

    测试数据 #4: Accepted, time = 15 ms, mem = 980 KiB, score = 10

    测试数据 #5: Accepted, time = 0 ms, mem = 984 KiB, score = 10

    测试数据 #6: Accepted, time = 15 ms, mem = 976 KiB, score = 10

    测试数据 #7: Accepted, time = 7 ms, mem = 976 KiB, score = 10

    测试数据 #8: Accepted, time = 15 ms, mem = 976 KiB, score = 10

    测试数据 #9: Accepted, time = 15 ms, mem = 976 KiB, score = 10

    Accepted, time = 82 ms, mem = 984 KiB, score = 100

  • 0
    @ 2014-09-27 20:45:15

    评测结果
    编译成功

    Free Pascal Compiler version 2.6.2 [2013/02/12] for i386
    Copyright (c) 1993-2012 by Florian Klaempfl and others
    Target OS: Win32 for i386
    Compiling foo.pas
    foo.pas(6,3) Note: Local variable "i1" not used
    foo.pas(6,6) Note: Local variable "j1" not used
    foo.pas(6,15) Note: Local variable "a" not used
    foo.pas(6,17) Note: Local variable "b" not used
    foo.pas(6,19) Note: Local variable "g" not used
    foo.pas(6,21) Note: Local variable "k" not used
    Linking foo.exe
    22 lines compiled, 0.1 sec , 28208 bytes code, 1628 bytes data
    6 note(s) issued
    测试数据 #0: Accepted, time = 15 ms, mem = 772 KiB, score = 10
    测试数据 #1: Accepted, time = 0 ms, mem = 772 KiB, score = 10
    测试数据 #2: Accepted, time = 0 ms, mem = 772 KiB, score = 10
    测试数据 #3: Accepted, time = 0 ms, mem = 772 KiB, score = 10
    测试数据 #4: Accepted, time = 0 ms, mem = 772 KiB, score = 10
    测试数据 #5: Accepted, time = 15 ms, mem = 772 KiB, score = 10
    测试数据 #6: Accepted, time = 15 ms, mem = 772 KiB, score = 10
    测试数据 #7: Accepted, time = 15 ms, mem = 772 KiB, score = 10
    测试数据 #8: Accepted, time = 15 ms, mem = 772 KiB, score = 10
    测试数据 #9: Accepted, time = 15 ms, mem = 772 KiB, score = 10
    Accepted, time = 90 ms, mem = 772 KiB, score = 100
    #代码

    type AA=record
    a,b,g,k:longint;
    end;
    var
    i,i1,j1,x,y,n,a,b,g,k,p:longint;
    f:array[0..10000]of AA;
    begin
    readln(n);
    for i:=1 to n do readln(f[i].a,f[i].b,f[i].g,f[i].k);
    readln(x,y);
    i:=n;
    p:=-1;
    while(i>0) do begin
    if (f[i].a+f[i].g-1>=x)and(x>=f[i].a)and(f[i].b+f[i].k-1>=y)and(y>=f[i].b) then
    begin
    p:=i;
    break;
    end;
    dec(i);
    end;
    writeln(p);
    end.

  • 0
    @ 2014-08-20 09:07:30

    AC代码.....优化到最优...
    var f:array[1..10000,1..4]of longint;
    n,s,x,y,a:longint;
    begin
    readln(n); a:=0;
    for s:=1 to n do
    readln(f[s,1],f[s,2],f[s,3],f[s,4]);
    readln(x,y);
    for s:=1 to n do
    if (x>=f[s,1])and(x<=f[s,3]+f[s,1])and(y>=f[s,2])and(y<=f[s,4]+f[s,2])
    then a:=s;
    if a<>0 then writeln(a) else writeln(-1);
    end.

  • 0
    @ 2014-07-21 17:47:07

    #include <cstdio>

    const int MAXN = 10000+10;

    int n, x, y, a[MAXN], b[MAXN], g[MAXN], k[MAXN];

    inline int Solve(){
    for (int i=n; i>0; i--)
    if (a[i]<=x && x<=a[i]+g[i] && b[i]<=y && y<=b[i]+k[i]) return i;
    return -1;
    }

    int main(){
    scanf("%d", &n);
    for (int i=1; i<=n; i++)
    scanf("%d %d %d %d", &a[i], &b[i], &g[i], &k[i]);
    scanf("%d %d", &x, &y);
    printf("%d\n", Solve());
    }

  • 0
    @ 2014-06-18 17:36:53

    #include <cstdio>
    int main()
    { int n;
    scanf("%d", &n);
    int a[n][4];
    for (int i=0;i<n;i++)
    for (int j=0;j<4;j++)
    scanf("%d", &a[i][j]);
    int x,y;
    scanf("%d%d", &x, &y);
    for (int i=n-1;i>=0;i--)
    { int xrange=a[i][0]+a[i][2],yrange=a[i][1]+a[i][3];
    if ((x>=a[i][0] && x<=xrange) && (y>=a[i][1] && y<=yrange))
    { printf("%d\n", i+1); break;}
    if (i==0)
    printf("-1\n");
    }

    return 0;
    }

  • 0
    @ 2014-05-01 23:56:24

    #include "cstdio"
    #include "vector"
    using namespace std;
    struct ditan{
    int a;int b;int g;int k;
    };
    vector<ditan>v;
    int n,x,y,ans=-1;
    int main(){
    scanf("%d\n",&n);
    for (int i=0; i<n; i++) {
    ditan tmp;
    scanf("%d %d %d %d\n",&tmp.a,&tmp.b,&tmp.g,&tmp.k);
    v.push_back(tmp);
    }
    scanf("%d %d\n",&x,&y);
    for (int i=0; i<n; i++) {
    if((v[i].a<=x&&x<v[i].a+v[i].g)&&(v[i].b<=y&&y<v[i].b+v[i].k))ans=i+1;
    else;
    }
    if(ans>-1)printf("%d\n",ans);
    else printf("-1\n");
    }

  • 0
    @ 2014-01-01 12:01:48

    Vijos 题解:http://hi.baidu.com/umule/item/2c997f8ed9600fdae596e017
    有疑问请留言 共同进步

  • 0
    @ 2013-10-30 15:54:57

    var
    n,x,y,i,j,k,a,b,g,fx,fy:longint;
    f:array[1..100000,1..6] of longint;
    begin
    readln(n);
    for i:=1 to n do
    begin
    read(a,b,g,k);
    f[i,1]:=a;f[i,2]:=b;f[i,3]:=g;f[i,4]:=k;
    f[i,5]:=a+g;f[i,6]:=b+k;
    end;
    readln;
    read(x,y);
    j:=-1;
    for i:=1 to n do
    if (f[i,1]>x)or(f[i,2]>y) then continue
    else
    begin
    if (f[i,5]>=x)and(f[i,6]>=y) then j:=i;
    end;
    writeln(j);
    end.

    有点水。

  • 0
    @ 2013-08-10 15:20:06

    ( ̄_ ̄|||) 竟然把复制的测试数据提交了 WA了一次

    Var x,y,x1,y1:array[1..10000] of longint;
    a,b,a1,b1,n,i,j:longint;
    Begin
    readln(n);
    For i:=1 to n do
    Begin
    readln(a,b,a1,b1);
    a1:=a+a1; b1:=b+b1;
    x[i]:=a; y[i]:=b;
    x1[i]:=a1; y1[i]:=b1;
    End;
    Readln(a,b);
    For i:=n downto 1 do
    If (a>=x[i]) and (a<=x1[i]) and (b>=y[i]) and (b<=y1[i]) then
    begin
    writeln(i);
    halt;
    end;
    writeln(-1);
    readln;
    end.

  • 0
    @ 2013-06-15 22:47:55

    #include <cstdio>

    using namespace std;

    #define MAXN 10000

    int q[MAXN][4];
    int n;
    int x,y;

    int main(){
    scanf("%d",&n);
    for (int i=0;i<n;i++){
    scanf("%d%d%d%d",&q[i][0],&q[i][1],&q[i][2],&q[i][3]);
    }
    scanf("%d%d",&x,&y);
    int ans=-1;
    for (int i=0;i<n;i++){
    if (x>=q[i][0]&&x<=q[i][0]+q[i][2]&&y>=q[i][1]&&y<=q[i][1]+q[i][3]){
    ans=i+1;
    }
    }
    printf("%d\n",ans);
    return 0;
    }

  • 0
    @ 2012-11-08 20:49:08

    #include

    using namespace std;

    int main()

    {

    int m,n,t,i,s=-1;

    int x[10000],y[10000],a[10000],b[10000];

    cin>>t;

    for(i=0;i>x[i]>>y[i]>>a[i]>>b[i];

    cin>>m>>n;

    for(i=t-1;i>=0;i--)

    if(m=x[i] && n=y[i]) {s=i+1; break;}

    cout

  • 0
    @ 2012-11-01 21:33:36

    测评机又抽啦!!!!

    本人提交:第一次,超时一个点;第二次,超时一个点;第三次,超时一个点,第四次,超时三个点;第五次,AC!!!!!!!!!!!!!!!

    同样的程序啊!

    不过话说回来,这题一点也不难哈,18行搞定!

    program P1736;

    var

    a,b,c,d:array[1..10000] of longint;

    g,k,x,y:longint;

    i,n:integer;

    begin

    readln(n);

    for i:=1 to n do

    begin

    read(a[i],b[i],g,k);

    c[i]:=a[i]+g;

    d[i]:=b[i]+k;

    end;

    read(x,y);

    for i:=n downto 1 do

    if (x>=a[i])and(x=b[i])and(y

  • 0
    @ 2012-10-27 11:48:31

    编译通过...

    ├ 测试数据 01:答案正确... (0ms, 736KB)

    ├ 测试数据 02:答案正确... (0ms, 736KB)

    ├ 测试数据 03:答案正确... (0ms, 736KB)

    ├ 测试数据 04:答案正确... (0ms, 736KB)

    ├ 测试数据 05:答案正确... (0ms, 736KB)

    ├ 测试数据 06:答案正确... (0ms, 736KB)

    ├ 测试数据 07:答案正确... (0ms, 736KB)

    ├ 测试数据 08:答案正确... (0ms, 736KB)

    ├ 测试数据 09:答案正确... (0ms, 736KB)

    ├ 测试数据 10:答案正确... (0ms, 736KB)

    ---|---|---|---|---|---|---|---|-

    Accepted / 100 / 0ms / 736KB

    SecretAgent的思路是对的

  • 0
    @ 2012-10-26 21:33:04

    二维线段树900ms+...

  • 0
    @ 2012-10-08 20:42:53

    沙发~

    把坐标按顺序存好

    反向检查输出答案

  • -1
    @ 2017-07-28 20:45:50

    //读入优化

    #include<cstdio>
    using namespace std;
    template<class T> inline void read(T &_a){
        bool f=0;int _ch=getchar();_a=0;
        while(_ch<'0' || _ch>'9'){if(_ch=='-')f=1;_ch=getchar();}
        while(_ch>='0' && _ch<='9'){_a=(_a<<1)+(_a<<3)+_ch-'0';_ch=getchar();}
        if(f)_a=-_a;
    }
    struct ditan{ int x,y,g,k; } t[10001];
    int n,x,y,ans;
    int main()
    {
        read(n);
        for (int i=1;i<=n;i++)
         read(t[i].x),read(t[i].y),read(t[i].g),read(t[i].k);
        read(x);read(y);
        for (int i=1;i<=n;i++)
         if(x>=t[i].x&&x<=t[i].x+t[i].g&&y>=t[i].y&&y<=t[i].y+t[i].k)
          ans=i;
        printf("%d",ans);
        return 0;
    }
    
  • -1
    @ 2016-10-22 13:18:34

    几分钟就解决了

  • -1
    @ 2016-10-22 13:18:22

    简单的模拟题吧。。。

信息

ID
1736
难度
4
分类
搜索 | 枚举 点击显示
标签
递交数
4969
已通过
2205
通过率
44%
被复制
14
上传者