답안 #16276

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
16276 2015-08-20T00:59:42 Z eaststar 버스 (JOI14_bus) C++14
컴파일 오류
0 ms 0 KB
#include <stdio.h>
#include <algorithm>
using namespace std;
struct data{
    int a,b,x,y;
    bool operator<(const data&r)const{
        if(a==r.a)return x>r.x;
        return a<r.a;
    }
}a[300010];
struct ans{
    int s,e;
    bool operator<(const ans&r)const{
        if(e==r.e)return s>r.s;
        return e>r.e;
    }
}b[100010],t;
int st[100010],chk[100010],m[100010],cnt,n;
int f(int p,int t){
    int i;
    if(p==n)return t;
  	if(chk[p])return m[p];
  	chk[p]=1,m[p]=1e9;
    for(i=st[p];a[i].a==p&&a[i].x>=t;++i)m[p]=min(m[p],f(a[i].b,a[i].y));
    return m[p];
}
int main(){
    int i,q;
    scanf("%d%d",&n,&m);
    for(i=1;i<=m;++i)scanf("%d%d%d%d",&a[i].a,&a[i].b,&a[i].x,&a[i].y);
    sort(a+1,a+m+1);
    for(i=1;i<=m;++i)if(a[i].a!=a[i-1].a)st[a[i].a]=i;
    for(i=1;a[i].a==1;++i)b[cnt].s=a[i].x,b[cnt++].e=f(1,a[i].x);
    sort(b,b+cnt);
    scanf("%d",&q);
    for(;q--;){
        scanf("%d",&t.e);
        i=lower_bound(b,b+cnt,t)-b;
        printf("%d\n",i==cnt?-1:b[i].s);
    }
    return 0;
}

Compilation message

bus.cpp: In function ‘int main()’:
bus.cpp:29:23: warning: format ‘%d’ expects argument of type ‘int*’, but argument 3 has type ‘int (*)[100010]’ [-Wformat=]
     scanf("%d%d",&n,&m);
                       ^
bus.cpp:30:16: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
     for(i=1;i<=m;++i)scanf("%d%d%d%d",&a[i].a,&a[i].b,&a[i].x,&a[i].y);
                ^
bus.cpp:31:16: error: invalid operands of types ‘data [300010]’ and ‘int [100010]’ to binary ‘operator+’
     sort(a+1,a+m+1);
                ^
bus.cpp:32:16: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
     for(i=1;i<=m;++i)if(a[i].a!=a[i-1].a)st[a[i].a]=i;
                ^
bus.cpp:29:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d",&n,&m);
                        ^
bus.cpp:30:71: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     for(i=1;i<=m;++i)scanf("%d%d%d%d",&a[i].a,&a[i].b,&a[i].x,&a[i].y);
                                                                       ^
bus.cpp:35:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&q);
                   ^
bus.cpp:37:25: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&t.e);
                         ^