Submission #199980

# Submission time Handle Problem Language Result Execution time Memory
199980 2020-02-04T15:44:28 Z mdn2002 San (COCI17_san) C++14
Compilation error
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
long long n,k,a[44],b[44],nm,tree[10000007],ans;
vector<pair<long long,long long> >on,to;.
vector<long long>vt,tk;
map<long long,long long>mp;
void up(int nod,int l,int r,int x)
{
    if(x<l||r<x)return;
    if(l==r)
    {
        tree[nod]++;
        return;
    }
    int mid=(l+r)/2;
    up(nod*2,l,mid,x);
    up(nod*2+1,mid+1,r,x);
    tree[nod]=tree[nod*2]+tree[nod*2+1];
}
long long qr(int nod,int l,int r,int x,int y)
{
    if(x<=l&&r<=y)return tree[nod];
    if(y<l||r<x)return 0;
    int mid=(l+r)/2;
    return qr(nod*2,l,mid,x,y)+qr(nod*2+1,mid+1,r,x,y);
}
void bt(int x,int mx,long long sum)
{
    if(sum>=k)ans++;
    if(sum>0)
    {
        if(mx==n/2)on.push_back({a[x],sum});
        else
        {
            to.push_back({a[x],sum});
            tk.push_back(sum);
        }
        vt.push_back(sum);
    }
    for(int i=x+1; i<=mx; i++)
    {
        if(a[x]<=a[i])bt(i,mx,sum+b[i]);
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen("gpsduel.in","r",stdin);
    //freopen("gpsduel.out","w",stdout);
    cin>>n>>k;
    for(int i=1; i<=n; i++)cin>>a[i]>>b[i];
    for(int i=1; i<=n/2; i++)bt(i,n/2,b[i]);
    for(int i=(n/2)+1; i<=n; i++)bt(i,n,b[i]);
    sort(on.begin(),on.end());
    sort(to.begin(),to.end());
    sort(vt.begin(),vt.end());
    sort(tk.begin(),tk.end());
    for(int i=0; i<vt.size(); i++)
    {
        if(mp[vt[i]]==0)mp[vt[i]]=++nm;
    }
    int l=to.size()-1;
    for(int i=on.size()-1; i>=0; i--)
    {
        long long x=on[i].first,y=on[i].second;
        for(l; l>=0; l--)
        {
            if(to[l].first<x)break;
            long long sm=to[l].second;
            up(1,0,(1<<20)+45,mp[sm]);
        }
        long long kk=*lower_bound(tk.begin(),tk.end(),k-y);
        if(lower_bound(tk.begin(),tk.end(),k-y)!=tk.end())
        {
            ans+=qr(1,0,(1<<20)+45,mp[kk],(1<<20)+45);
        }
    }
    cout<<ans;
}

Compilation message

san.cpp:5:41: error: expected unqualified-id before '.' token
 vector<pair<long long,long long> >on,to;.
                                         ^
san.cpp: In function 'void bt(int, int, long long int)':
san.cpp:37:13: error: 'tk' was not declared in this scope
             tk.push_back(sum);
             ^~
san.cpp:37:13: note: suggested alternative: 'to'
             tk.push_back(sum);
             ^~
             to
san.cpp:39:9: error: 'vt' was not declared in this scope
         vt.push_back(sum);
         ^~
san.cpp:39:9: note: suggested alternative: 'bt'
         vt.push_back(sum);
         ^~
         bt
san.cpp: In function 'int main()':
san.cpp:59:10: error: 'vt' was not declared in this scope
     sort(vt.begin(),vt.end());
          ^~
san.cpp:59:10: note: suggested alternative: 'bt'
     sort(vt.begin(),vt.end());
          ^~
          bt
san.cpp:60:10: error: 'tk' was not declared in this scope
     sort(tk.begin(),tk.end());
          ^~
san.cpp:60:10: note: suggested alternative: 'to'
     sort(tk.begin(),tk.end());
          ^~
          to
san.cpp:69:14: warning: statement has no effect [-Wunused-value]
         for(l; l>=0; l--)
              ^