Submission #997979

# Submission time Handle Problem Language Result Execution time Memory
997979 2024-06-13T07:26:46 Z modwwe Treatment Project (JOI20_treatment) C++17
0 / 100
85 ms 30316 KB
#include<bits/stdc++.h>
#define int long long
//#define ll long long
#define down cout<<'\n';
#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;
const int inf=1e18;
void phongbeo();
const int mod2=1e9+7;
const int  mod1=998244353;
struct icd
{
    int a,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,f;

};
int n,m,s1,s2,s4,s3,sf,k,r,mid,s5,s6,mx,s7,s8,s9,mx2,res,dem2=0,dem=0,l;
int  i,s10,s12;
int el=29;
main()
{
#ifndef ONLINE_JUDGE
    //fin(task),fou(task);
#endif
    NHP
    /// cin>>s1;
    // modwwe
    phongbeo(),down
    checktime
}
id a[100001];
vector<int> v;
struct cmp
{
    bool operator()(ib a,ib b)
    {
        return a.a>b.a;
    }
};
bool color[100001];
int b[100001];
bool cmp3(ib a,ib b)
{
    return a.a<b.a;
}
struct IT
{
    vector<ib> v2[100001];
    int c[100001];
    ib t[400001];
    ib mer(ib a,ib b)
    {
        if(a.a<=b.a) return a;
        else return b;
    }

    void setup(int node,int l,int r)
    {
        if(l==r)
        {
            sort(v2[l].begin(),v2[l].end(),cmp3);
            if(v2[l].size()!=0)
                t[node]=v2[l][0];
                else t[node].a=1e18,t[node].b=0;
            return;
        }
        int mid=l+r>>1;
        setup(node<<1,l,mid);
        setup(node<<1|1,mid+1,r);
        t[node]=mer(t[node<<1],t[node<<1|1]);
    }
    void upd2(int node,int l,int r,int l1,int r1)
    {
        if(l>r1||r<l1) return;
        if(l>=l1&&r<=r1)
        {
            c[l]++;
            if(c[l]<v2[l].size())
            {
                t[node]=v2[l][c[l]];
            }
            else t[node].a=1e18,t[node].b=0;
            return;
        }
        int mid=l+r>>1;
        upd2(node<<1,l,mid,l1,r1);
        upd2(node<<1|1,mid+1,r,l1,r1);
        t[node]=mer(t[node<<1],t[node<<1|1]);
    }
    void upd(int node,int l,int r,int l1,int r1,ib x)
    {
        if(l>r1||r<l1) return;
        if(l>=l1&&r<=r1)
        {
            v2[l].pb(x);
            return;
        }
        int mid=l+r>>1;
        upd(node<<1,l,mid,l1,r1,x);
        upd(node<<1|1,mid+1,r,l1,r1,x);
    }
    ib get(int node,int l,int r,int l1,int r1)
    {
        if(l>r1||r<l1) return{inf,0};
        if(l>=l1&&r<=r1) return t[node];
        int mid=l+r>>1;
        return mer(get(node<<1,l,mid,l1,r1),get(node<<1|1,mid+1,r,l1,r1)) ;
    }
} st1,st2;
void phongbeo()
{
    cin>>n>>m;
    for(int i=1; i<=m; i++)
        cin>>a[i].a>>a[i].b>>a[i].c>>a[i].d,a[i].b--,v.pb(a[i].a),b[i]=a[i].a;
/// cost i->j =a[j]
/// find min(cost(i))
    sort(v.begin(),v.end());
    for(int i=1; i<=m; i++)
    {
        a[i].a=lower_bound(v.begin(),v.end(),a[i].a)-v.begin()+1;
       if(a[i].b!=0)st1.upd(1,1,m,a[i].a,a[i].a, {a[i].b+b[i],i}),
        st2.upd(1,1,m,a[i].a,a[i].a, {a[i].b-b[i],i});
    }
    st1.setup(1,1,m);
    st2.setup(1,1,m);
    priority_queue<ib,vector<ib>,cmp>p;
    for(int i=1;i<=m;i++)
         if(a[i].b==0)
        p.push({a[i].d,i});
 while(!p.empty())
 {
      ib x=p.top();
      p.pop();
       if(a[x.b].c==n){
            cout<<x.a;
       exit(0);}
       if(color[x.b]) continue;
        color[x.b]=1;
        s3=a[x.b].c+b[x.b];
  while(true)/// task 1
  {
      ib ss2=st1.get(1,1,m,a[x.b].a,m);
        if(ss2.a<=s3)
        {
            p.push({a[ss2.b].d+x.a,ss2.b});
            st1.upd2(1,1,m,a[ss2.b].a,a[ss2.b].a);
            st2.upd2(1,1,m,a[ss2.b].a,a[ss2.b].a);
        }
        else break;
  }
   s3=a[x.b].c-b[x.b];
  while(true)/// task 1
  {
       ib ss2=st2.get(1,1,m,1,a[x.b].a);
        if(ss2.a<=s3)
        {
            p.push({a[ss2.b].d+x.a,ss2.b});
            st1.upd2(1,1,m,a[ss2.b].a,a[ss2.b].a);
            st2.upd2(1,1,m,a[ss2.b].a,a[ss2.b].a);
        }
        else break;
  }
 }
}

Compilation message

treatment.cpp:44:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   44 | main()
      | ^~~~
treatment.cpp: In member function 'void IT::setup(long long int, long long int, long long int)':
treatment.cpp:91:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   91 |         int mid=l+r>>1;
      |                 ~^~
treatment.cpp: In member function 'void IT::upd2(long long int, long long int, long long int, long long int, long long int)':
treatment.cpp:102:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<ib>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  102 |             if(c[l]<v2[l].size())
      |                ~~~~^~~~~~~~~~~~~
treatment.cpp:109:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  109 |         int mid=l+r>>1;
      |                 ~^~
treatment.cpp: In member function 'void IT::upd(long long int, long long int, long long int, long long int, long long int, ib)':
treatment.cpp:122:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  122 |         int mid=l+r>>1;
      |                 ~^~
treatment.cpp: In member function 'ib IT::get(long long int, long long int, long long int, long long int, long long int)':
treatment.cpp:130:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  130 |         int mid=l+r>>1;
      |                 ~^~
# Verdict Execution time Memory Grader output
1 Correct 85 ms 29076 KB Output is correct
2 Incorrect 83 ms 30316 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 12892 KB Output is correct
2 Correct 2 ms 12892 KB Output is correct
3 Correct 2 ms 12892 KB Output is correct
4 Correct 3 ms 12892 KB Output is correct
5 Incorrect 2 ms 12892 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 12892 KB Output is correct
2 Correct 2 ms 12892 KB Output is correct
3 Correct 2 ms 12892 KB Output is correct
4 Correct 3 ms 12892 KB Output is correct
5 Incorrect 2 ms 12892 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 85 ms 29076 KB Output is correct
2 Incorrect 83 ms 30316 KB Output isn't correct
3 Halted 0 ms 0 KB -