Submission #519177

# Submission time Handle Problem Language Result Execution time Memory
519177 2022-01-25T20:14:53 Z A_D Global Warming (CEOI18_glo) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
 
#define int long long
#define ii pair<int,int>
#define F first
#define S second
 
using namespace std;
const int N=2e5+100;
int a[N];
map<int,int> mp;
set<int> st;
int seg1[4*N];
int seg2[4*N];
int b[N];
int freq[N];
int get1(int p,int s,int e,int a,int b)
{
    if(a<=s&&e<=b)return seg1[p];
    if(s>b||e<a)return 0;
    int mid=(s+e)/2;
    return max(get1(p*2,s,mid,a,b),get1(p*2+1,mid+1,e,a,b));
}
void update1(int p,int s,int e,int i,int v)
{
    if(s==e){
        seg1[p]=v;
        return;
    }
    int mid=(s+e)/2;
    if(i<=mid){
        update1(p*2,s,mid,i,v);
    }
    else{
        update1(p*2+1,mid+1,e,i,v);
    }
    seg1[p]=max(seg1[p*2],seg1[p*2+1]);
}
 
int get2(int p,int s,int e,int a,int b)
{
    if(a<=s&&e<=b)return seg2[p];
    if(s>b||e<a)return 0;
    int mid=(s+e)/2;
    return max(get2(p*2,s,mid,a,b),get2(p*2+1,mid+1,e,a,b));
}
 
 
 
void update2(int p,int s,int e,int i,int v)
{
    if(s==e){
        seg2[p]=v;
        return;
    }
    int mid=(s+e)/2;
    if(i<=mid){
        update2(p*2,s,mid,i,v);
    }
    else{
        update2(p*2+1,mid+1,e,i,v);
    }
    seg2[p]=max(seg2[p*2],seg2[p*2+1]);
}
 
 
void solve()
{
    int n,x;
    cin>>n>>x;
    for(int i=1;i<=n;i++){
        scanf("%lld",&a[i]);
        st.insert(a[i]);
    }
    int cnt=1;
    for(auto xxx:st){
        freq[cnt]=xxx;
        mp[xxx]=cnt++;
    }
    for(int i=1;i<=n;i++){
        a[i]=mp[a[i]];
    }
    for(int i=1;i<=n;i++){
        int v=0;
        if(a[i]!=1){
            v=get1(1,1,n,1,a[i]-1);
        }
        //cout<<v<<" ";
        b[i]=get1(1,1,n,a[i],a[i]);
        update1(1,1,n,a[i],v+1);
      //  cout<<b[i]<<" ";
    }
    //cout<<endl;
    int ans=get1(1,1,n,1,n);
    cout<<ans<<endl;
    return;
    /*
 //   cout<<seg1[1]<<endl;
    for(int i=n;i>1;i--){
        int v=0;
        if(a[i]!=n){
            v=get2(1,1,n,a[i]+1,n);
        }
        update2(1,1,n,a[i],v+1);
        //cout<<b[i]<<" ";
        update1(1,1,n,a[i],b[i]);
       // for(int j=1;j<=n;j++)cout<<get1(1,1,n,a[j],a[j])<<" ";cout<<endl;
        int l=1,r=cnt-1,ann;
        while(l<=r){
            int mid=(l+r)/2;
            if(freq[mid]<freq[a[i]]+x){
                l=mid+1;
                ann=mid;
            }
            else{
                r=mid-1;
            }
        }
  //      cout<<get1(1,1,n,1,ann)<<" "<<get2(1,1,n,a[i],n)<<endl;
        ans=max(ans,get2(1,1,n,a[i],n)+get1(1,1,n,1,ann));
    }
//    cout<<endl;
    cout<<ans<<endl;
    */
}
main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
}
 

Compilation message

glo.cpp:76:2: error: extended character   is not valid in an identifier
   76 |     for(auto xxx:st){
      |  ^
glo.cpp:76:5: error: extended character   is not valid in an identifier
   76 |     for(auto xxx:st){
      |    ^
glo.cpp:77:2: error: extended character   is not valid in an identifier
   77 |         freq[cnt]=xxx;
      |  ^
glo.cpp:77:5: error: extended character   is not valid in an identifier
   77 |         freq[cnt]=xxx;
      |    ^
glo.cpp:77:8: error: extended character   is not valid in an identifier
   77 |         freq[cnt]=xxx;
      |      ^
glo.cpp:77:11: error: extended character   is not valid in an identifier
   77 |         freq[cnt]=xxx;
      |        ^
glo.cpp:78:2: error: extended character   is not valid in an identifier
   78 |         mp[xxx]=cnt++;
      |  ^
glo.cpp:78:5: error: extended character   is not valid in an identifier
   78 |         mp[xxx]=cnt++;
      |    ^
glo.cpp:78:8: error: extended character   is not valid in an identifier
   78 |         mp[xxx]=cnt++;
      |      ^
glo.cpp:78:11: error: extended character   is not valid in an identifier
   78 |         mp[xxx]=cnt++;
      |        ^
glo.cpp: In function 'void solve()':
glo.cpp:76:2: error: '\U000000a0' was not declared in this scope
   76 |     for(auto xxx:st){
      |  ^
glo.cpp:75:9: warning: unused variable 'cnt' [-Wunused-variable]
   75 |     int cnt=1;
      |         ^~~
glo.cpp: At global scope:
glo.cpp:126:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
  126 | main()
      | ^~~~
glo.cpp: In function 'void solve()':
glo.cpp:72:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   72 |         scanf("%lld",&a[i]);
      |         ~~~~~^~~~~~~~~~~~~~