Submission #1099246

# Submission time Handle Problem Language Result Execution time Memory
1099246 2024-10-11T03:04:32 Z modwwe Employment (JOI16_employment) C++17
0 / 100
1 ms 612 KB
#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC optimize("conserve-stack")
#include<bits/stdc++.h>
//#define int long long
#define ll long long
#define down cout<<'\n';
#define debug cout<<" cucuucucuuu",down
#define NHP     ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
#define modwwe  int t;cin>>t; while(t--)
#define bit(i,j) (i>>j&1)
#define sobit(a) __builtin_popcountll(a)
#define task "test"
#define fin(x) freopen(x".inp","r",stdin)
#define fou(x) freopen(x".out","w",stdout)
#define pb push_back
#define checktime   cerr << (double)clock() / CLOCKS_PER_SEC * 1000  << " ms";
using namespace std;
#define getchar_unlocked getchar

inline int scan()
{
    char c = getchar_unlocked();
    int x = 0;
    while (c < '0' || c > '9')
    {
        c = getchar_unlocked();
    }
    while (c >= '0' && c <= '9')
    {
        x = (x << 1) + (x << 3) + c - '0';
        c = getchar_unlocked();
    }
    return x;
}

void phongbeo();
const int inf = 1e18;
const int mod2 = 1e9 + 7;
const int  mod1 = 998244353;
struct icd
{
    long double a;
    int b;
};
struct ib
{
    int a;
    int b;
};
struct ic
{
    int a, b, c;
};
struct id
{
    int a, b, c, d;
};
struct ie
{
    int a, b, c, d, e;

};

int n, m, s1, s2, s4, s3, sf, k, s5, s6, mx, s7, s8, s9, mx2, res, dem2 = 0, dem = 0, s33, dem3, dem4, l, r, mid, l2, r2, center;
int  i, s10, s12,k1,k2,k3,s11,t,lim,w;
int kk;
int el = 19;

main()
{
    if(fopen(task".inp","r"))
    {
        fin(task);
        fou(task);
    }
    NHP
    /// cin>>s1;
///modwwe
    phongbeo();
    // checktime
}
int a[200001];
int b[200001];

struct bit
{
    int bit[200001];
    void upd(int x,int y)
    {
        for(x; x<=n; x+=x&-x)
            bit[x]+=y;
    }
    int get(int x)
    {
        int s=0;
        for(x; x; x-=x&-x)
            s+=bit[x];
        return s;
    }
} fen;
void solve_left()
{
    for(int i=3; i<=n; i++)
    {
        if(a[i-1]<a[i])
        {
            fen.upd(a[i-1]+1,1),
                    fen.upd(a[i]+1,-1);
            // cout<<a[i-1]+1<<" "<<min(a[i]+1,b[i-1]+1),down
        }
    }
}
vector<int> v;
void phongbeo()
{
    cin>>n>>m;
    for(int i=1; i<=n; i++)
        cin>>a[i],v.pb(a[i]);
    sort(v.begin(),v.end());
    for(int i=1; i<=n; i++)
        a[i]=lower_bound(v.begin(),v.end(),a[i])-v.begin()+1;
    for(int i=1; i<=n; i++)
        b[i]=max(b[i-1],a[i]);
    solve_left();
    for(int i=1; i<=m; i++)
    {
        cin>>l>>r;
        if(l==2)assert(0);
        if(r>v.back())cout<<0,down
                              else
            {
                r=lower_bound(v.begin(),v.end(),r)-v.begin()+1;
s2=fen.get(r)+1;
            l2=1;
            r2=n;
             while(l2<=r2)
             {
                  int mid=l2+r2>>1;
                   if(b[mid]>=r)r2=mid-1;
                    else l2=mid+1;
             }
             r2++;
             if(r2!=1)
              if(a[r2-1]<a[r2])s2--;
               cout<<s2,down
            }
    }
}

Compilation message

employment.cpp:37:17: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   37 | const int inf = 1e18;
      |                 ^~~~
employment.cpp:69:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   69 | main()
      | ^~~~
employment.cpp: In member function 'void bit::upd(int, int)':
employment.cpp:90:13: warning: statement has no effect [-Wunused-value]
   90 |         for(x; x<=n; x+=x&-x)
      |             ^
employment.cpp: In member function 'int bit::get(int)':
employment.cpp:96:13: warning: statement has no effect [-Wunused-value]
   96 |         for(x; x; x-=x&-x)
      |             ^
employment.cpp: In function 'void phongbeo()':
employment.cpp:138:29: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  138 |                   int mid=l2+r2>>1;
      |                           ~~^~~
employment.cpp: In function 'int main()':
employment.cpp:13:23: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 | #define fin(x) freopen(x".inp","r",stdin)
      |                ~~~~~~~^~~~~~~~~~~~~~~~~~~
employment.cpp:73:9: note: in expansion of macro 'fin'
   73 |         fin(task);
      |         ^~~
employment.cpp:14:23: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 | #define fou(x) freopen(x".out","w",stdout)
      |                ~~~~~~~^~~~~~~~~~~~~~~~~~~~
employment.cpp:74:9: note: in expansion of macro 'fou'
   74 |         fou(task);
      |         ^~~
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 612 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 612 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -