답안 #260876

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
260876 2020-08-11T06:34:04 Z 최은수(#5044) 수확 (JOI20_harvest) C++17
컴파일 오류
0 ms 0 KB
#include<iostream>
#include<vector>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18;
vector<pl>lst[3010];
int chk[200010];
int cur;
ll time[200010];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,m,q;
    ll l,c;
    cin>>n>>m>>l>>c;
    vector<int>np(n);
    vector<ll>pp(n),app(m),npt(n);
    for(ll&t:pp)
        cin>>t;
    for(int i=0;i<n;i++)
    {
        ll t=pp[i];
        ll nxp=((t-c)%l+l)%l;
        np[i]=upper_bound(all(pp),nxp)-pp.begin()-1;
        if(np[i]<0)
            np[i]+=n;
        npt[i]=(pp[np[i]]>nxp?l-(pp[np[i]]-nxp):nxp-pp[np[i]])+c;
    }
    for(ll&t:app)
    {
        cin>>t;
        int id=upper_bound(all(pp),t)-pp.begin()-1;
        if(id<0)
            id+=n;
        ll tm=pp[id]>t?l-(pp[id]-t):t-pp[id];
        cur+=2;
        for(;chk[id]!=cur;tm+=npt[id],id=np[id])
        {
            if(chk[id]==cur-1)
            {
                lst[id].eb(time[id],tm-time[id]);
                chk[id]=cur;
            }
            else
            {
                lst[id].eb(time[id]=tm,-1);
                chk[id]=cur-1;
            }
            time[id]=tm;
        }
    }
    cin>>q;
    for(int i=0;i<q;i++)
    {
        int x;
        ll t;
        cin>>x>>t;
        x--;
        ll ans=0;
        for(pl&a:lst[x])
            if(t>=a.fi)
                ans+=a.se==-1?1:(t-a.fi)/a.se;
        cout<<ans<<'\n';
    }
    cout.flush();
    return 0;
}

Compilation message

harvest.cpp:18:15: error: 'll time [200010]' redeclared as different kind of symbol
 ll time[200010];
               ^
In file included from /usr/include/pthread.h:24:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/gthr-default.h:35,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/gthr.h:148,
                 from /usr/include/c++/7/ext/atomicity.h:35,
                 from /usr/include/c++/7/bits/ios_base.h:39,
                 from /usr/include/c++/7/ios:42,
                 from /usr/include/c++/7/ostream:38,
                 from /usr/include/c++/7/iostream:39,
                 from harvest.cpp:1:
/usr/include/time.h:192:15: note: previous declaration 'time_t time(time_t*)'
 extern time_t time (time_t *__timer) __THROW;
               ^~~~
harvest.cpp: In function 'int main()':
harvest.cpp:51:35: warning: pointer to a function used in arithmetic [-Wpointer-arith]
                 lst[id].eb(time[id],tm-time[id]);
                                   ^
harvest.cpp:51:47: warning: pointer to a function used in arithmetic [-Wpointer-arith]
                 lst[id].eb(time[id],tm-time[id]);
                                               ^
harvest.cpp:51:39: error: invalid operands of types 'll {aka long long int}' and 'time_t(time_t*) noexcept {aka long int(long int*) noexcept}' to binary 'operator-'
                 lst[id].eb(time[id],tm-time[id]);
                                     ~~^~~~~~~~~
harvest.cpp:56:35: warning: pointer to a function used in arithmetic [-Wpointer-arith]
                 lst[id].eb(time[id]=tm,-1);
                                   ^
harvest.cpp:56:37: error: assignment of read-only location '*(time + ((sizetype)id))'
                 lst[id].eb(time[id]=tm,-1);
                                     ^~
harvest.cpp:56:37: error: cannot convert 'll {aka long long int}' to 'time_t(time_t*) noexcept {aka long int(long int*) noexcept}' in assignment
harvest.cpp:59:20: warning: pointer to a function used in arithmetic [-Wpointer-arith]
             time[id]=tm;
                    ^
harvest.cpp:59:22: error: assignment of read-only location '*(time + ((sizetype)id))'
             time[id]=tm;
                      ^~
harvest.cpp:59:22: error: cannot convert 'll {aka long long int}' to 'time_t(time_t*) noexcept {aka long int(long int*) noexcept}' in assignment