Submission #1052961

# Submission time Handle Problem Language Result Execution time Memory
1052961 2024-08-11T06:44:30 Z modwwe Horses (IOI15_horses) C++17
Compilation error
0 ms 0 KB
//https://www.instagram.com/_modwwe/
#pragma GCC optimize("Ofast,unroll-loops")
#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".ans","w",stdout)
#define pb push_back
#define checktime   cerr << (double)clock() / CLOCKS_PER_SEC * 1000  << " ms";
using namespace std;
void phongbeo();
const ll inf=1e18;
const int mod2=1e9+7;
const int  mod1=998244353;
struct icd
{
    long double a;
    int b;
};
struct ib
{
    ll a;
    ll 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,l,r,mid;
int  i,s10,s12;
int kk;
int el=29;

set<int> s;
int a[500001];
int b[500001];
struct IT
{    int t[2000001];

     void build(int node,int l,int r)
      {
           if(l==r){t[node]=a[l]; return;}
           int mid=l+r>>1;
            build(node<<1,l,mid);
            build(node<<1|1,mid+1,r);
             t[node]=t[node<<1]*t[node<<1|1]%mod2;
      }
      void upd(int node,int l,int r,int l1)
      {
           if(l==r){t[node]=a[l]; return;}
           int mid=l+r>>1;
            if(l1<=mid)upd(node<<1,l,mid,l1);
             else upd(node<<1|1,mid+1,r,l1);
              t[node]=t[node<<1]*t[node<<1|1]%mod2;
      }
      int get(int node,int l,int r,int l1,int r1)
        {
             if(l>r1||r<l1) return 1;
             if(l>=l1&&r<=r1) return t[node];
              int mid=l+r>>1;
               return get(node<<1,l,mid,l1,r1)*get(node<<1|1,mid+1,r,l1,r1)%mod2;
        }
}st;
struct IT2{
    int t[2000001];
void build(int node,int l,int r)
      {
           if(l==r){t[node]=b[l]; return;}
           int mid=l+r>>1;
            build(node<<1,l,mid);
            build(node<<1|1,mid+1,r);
             t[node]=max(t[node<<1],t[node<<1|1]);
      }
      void upd(int node,int l,int r,int l1)
      {
           if(l==r){t[node]=b[l]; return;}
           int mid=l+r>>1;
            if(l1<=mid)upd(node<<1,l,mid,l1);
             else upd(node<<1|1,mid+1,r,l1);
             t[node]=max(t[node<<1],t[node<<1|1]);
      }
      int get(int node,int l,int r,int l1,int r1)
        {
             if(l>r1||r<l1) return 1;
             if(l>=l1&&r<=r1) return t[node];
              int mid=l+r>>1;
               return max(get(node<<1,l,mid,l1,r1),get(node<<1|1,mid+1,r,l1,r1));
        }
}st2;
void setup()
 {
      for(int i=n;i>=1;--i)
         if(a[i]!=1)
          s.insert(i);
          s.insert(1);
        auto x=s.end();
        x--;
        s2=0;
        s5=n;
        while(1)
        {
            s6=st2.get(1,1,n,*x,s5);
            if(s6>s2) s3=*x,s2=s6,s8=s6;
         s2=s2*a[*x];
         s5=*x-1;
         if(x==s.begin()) break;
x--;
          if(s2>1e9) break;
        }
 }
 void setup2()
 {
       auto x=s.end();
                 s.insert(1);
        x--;
        s2=0;
        s5=n;
        s3=0;
        s8=0;
        while(1)
        {
            s6=st2.get(1,1,n,*x,s5);
            if(s6>s2) s3=*x,s2=s6,s8=s6;
         s2=s2*a[*x];
         s5=*x-1;
         if(x==s.begin()) break;
x--;
          if(s2>1e9) break;
        }
 }
int init(int N,int X[],int Y[])
{
n=N;
   for(int i=1;i<=n;i++)
    a[i]=X[i-1];
    for(int i=1;i<=n;i++)
         b[i]=Y[i-1];
     st.build(1,1,n);
     st2.build(1,1,n);
     setup();
s3=s8*st.get(1,1,n,1,s3)%mod2;
 return s3;
}
int updateX(int pos, int val)
{
    l=pos;
    r=val;
      l++;
    b[l]=r;
    st2.upd(1,1,n,l);
    setup2();
    s3=s8*st.get(1,1,n,1,s3)%mod2;
 return s3;
}
int updateY(int pos, int val)
{
    l=pos;
    r=val;
     l++;
         if(a[l]!=1&&r==1) s.erase(l);
          if(a[l]==1&&r!=1) s.insert(l);
          a[l]=r;
           st.upd(1,1,n,l);
           setup2();
           s3=s8*st.get(1,1,n,1,s3)%mod2;
 return s3;
}

Compilation message

horses.cpp: In member function 'void IT::build(long long int, long long int, long long int)':
horses.cpp:57:36: warning: declaration of 'r' shadows a global declaration [-Wshadow]
   57 |      void build(int node,int l,int r)
      |                                    ^
horses.cpp:46:76: note: shadowed declaration is here
   46 | int n,m,s1,s2,s4,s3,sf,k,s5,s6,mx,s7,s8,s9,mx2,res,dem2=0,dem=0,s33,dem3,l,r,mid;
      |                                                                            ^
horses.cpp:57:30: warning: declaration of 'l' shadows a global declaration [-Wshadow]
   57 |      void build(int node,int l,int r)
      |                              ^
horses.cpp:46:74: note: shadowed declaration is here
   46 | int n,m,s1,s2,s4,s3,sf,k,s5,s6,mx,s7,s8,s9,mx2,res,dem2=0,dem=0,s33,dem3,l,r,mid;
      |                                                                          ^
horses.cpp:60:16: warning: declaration of 'mid' shadows a global declaration [-Wshadow]
   60 |            int mid=l+r>>1;
      |                ^~~
horses.cpp:46:78: note: shadowed declaration is here
   46 | int n,m,s1,s2,s4,s3,sf,k,s5,s6,mx,s7,s8,s9,mx2,res,dem2=0,dem=0,s33,dem3,l,r,mid;
      |                                                                              ^~~
horses.cpp:60:21: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   60 |            int mid=l+r>>1;
      |                    ~^~
horses.cpp: In member function 'void IT::upd(long long int, long long int, long long int, long long int)':
horses.cpp:65:35: warning: declaration of 'r' shadows a global declaration [-Wshadow]
   65 |       void upd(int node,int l,int r,int l1)
      |                                   ^
horses.cpp:46:76: note: shadowed declaration is here
   46 | int n,m,s1,s2,s4,s3,sf,k,s5,s6,mx,s7,s8,s9,mx2,res,dem2=0,dem=0,s33,dem3,l,r,mid;
      |                                                                            ^
horses.cpp:65:29: warning: declaration of 'l' shadows a global declaration [-Wshadow]
   65 |       void upd(int node,int l,int r,int l1)
      |                             ^
horses.cpp:46:74: note: shadowed declaration is here
   46 | int n,m,s1,s2,s4,s3,sf,k,s5,s6,mx,s7,s8,s9,mx2,res,dem2=0,dem=0,s33,dem3,l,r,mid;
      |                                                                          ^
horses.cpp:68:16: warning: declaration of 'mid' shadows a global declaration [-Wshadow]
   68 |            int mid=l+r>>1;
      |                ^~~
horses.cpp:46:78: note: shadowed declaration is here
   46 | int n,m,s1,s2,s4,s3,sf,k,s5,s6,mx,s7,s8,s9,mx2,res,dem2=0,dem=0,s33,dem3,l,r,mid;
      |                                                                              ^~~
horses.cpp:68:21: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   68 |            int mid=l+r>>1;
      |                    ~^~
horses.cpp: In member function 'long long int IT::get(long long int, long long int, long long int, long long int, long long int)':
horses.cpp:73:34: warning: declaration of 'r' shadows a global declaration [-Wshadow]
   73 |       int get(int node,int l,int r,int l1,int r1)
      |                                  ^
horses.cpp:46:76: note: shadowed declaration is here
   46 | int n,m,s1,s2,s4,s3,sf,k,s5,s6,mx,s7,s8,s9,mx2,res,dem2=0,dem=0,s33,dem3,l,r,mid;
      |                                                                            ^
horses.cpp:73:28: warning: declaration of 'l' shadows a global declaration [-Wshadow]
   73 |       int get(int node,int l,int r,int l1,int r1)
      |                            ^
horses.cpp:46:74: note: shadowed declaration is here
   46 | int n,m,s1,s2,s4,s3,sf,k,s5,s6,mx,s7,s8,s9,mx2,res,dem2=0,dem=0,s33,dem3,l,r,mid;
      |                                                                          ^
horses.cpp:77:19: warning: declaration of 'mid' shadows a global declaration [-Wshadow]
   77 |               int mid=l+r>>1;
      |                   ^~~
horses.cpp:46:78: note: shadowed declaration is here
   46 | int n,m,s1,s2,s4,s3,sf,k,s5,s6,mx,s7,s8,s9,mx2,res,dem2=0,dem=0,s33,dem3,l,r,mid;
      |                                                                              ^~~
horses.cpp:77:24: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   77 |               int mid=l+r>>1;
      |                       ~^~
horses.cpp: In member function 'void IT2::build(long long int, long long int, long long int)':
horses.cpp:83:31: warning: declaration of 'r' shadows a global declaration [-Wshadow]
   83 | void build(int node,int l,int r)
      |                               ^
horses.cpp:46:76: note: shadowed declaration is here
   46 | int n,m,s1,s2,s4,s3,sf,k,s5,s6,mx,s7,s8,s9,mx2,res,dem2=0,dem=0,s33,dem3,l,r,mid;
      |                                                                            ^
horses.cpp:83:25: warning: declaration of 'l' shadows a global declaration [-Wshadow]
   83 | void build(int node,int l,int r)
      |                         ^
horses.cpp:46:74: note: shadowed declaration is here
   46 | int n,m,s1,s2,s4,s3,sf,k,s5,s6,mx,s7,s8,s9,mx2,res,dem2=0,dem=0,s33,dem3,l,r,mid;
      |                                                                          ^
horses.cpp:86:16: warning: declaration of 'mid' shadows a global declaration [-Wshadow]
   86 |            int mid=l+r>>1;
      |                ^~~
horses.cpp:46:78: note: shadowed declaration is here
   46 | int n,m,s1,s2,s4,s3,sf,k,s5,s6,mx,s7,s8,s9,mx2,res,dem2=0,dem=0,s33,dem3,l,r,mid;
      |                                                                              ^~~
horses.cpp:86:21: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   86 |            int mid=l+r>>1;
      |                    ~^~
horses.cpp: In member function 'void IT2::upd(long long int, long long int, long long int, long long int)':
horses.cpp:91:35: warning: declaration of 'r' shadows a global declaration [-Wshadow]
   91 |       void upd(int node,int l,int r,int l1)
      |                                   ^
horses.cpp:46:76: note: shadowed declaration is here
   46 | int n,m,s1,s2,s4,s3,sf,k,s5,s6,mx,s7,s8,s9,mx2,res,dem2=0,dem=0,s33,dem3,l,r,mid;
      |                                                                            ^
horses.cpp:91:29: warning: declaration of 'l' shadows a global declaration [-Wshadow]
   91 |       void upd(int node,int l,int r,int l1)
      |                             ^
horses.cpp:46:74: note: shadowed declaration is here
   46 | int n,m,s1,s2,s4,s3,sf,k,s5,s6,mx,s7,s8,s9,mx2,res,dem2=0,dem=0,s33,dem3,l,r,mid;
      |                                                                          ^
horses.cpp:94:16: warning: declaration of 'mid' shadows a global declaration [-Wshadow]
   94 |            int mid=l+r>>1;
      |                ^~~
horses.cpp:46:78: note: shadowed declaration is here
   46 | int n,m,s1,s2,s4,s3,sf,k,s5,s6,mx,s7,s8,s9,mx2,res,dem2=0,dem=0,s33,dem3,l,r,mid;
      |                                                                              ^~~
horses.cpp:94:21: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   94 |            int mid=l+r>>1;
      |                    ~^~
horses.cpp: In member function 'long long int IT2::get(long long int, long long int, long long int, long long int, long long int)':
horses.cpp:99:34: warning: declaration of 'r' shadows a global declaration [-Wshadow]
   99 |       int get(int node,int l,int r,int l1,int r1)
      |                                  ^
horses.cpp:46:76: note: shadowed declaration is here
   46 | int n,m,s1,s2,s4,s3,sf,k,s5,s6,mx,s7,s8,s9,mx2,res,dem2=0,dem=0,s33,dem3,l,r,mid;
      |                                                                            ^
horses.cpp:99:28: warning: declaration of 'l' shadows a global declaration [-Wshadow]
   99 |       int get(int node,int l,int r,int l1,int r1)
      |                            ^
horses.cpp:46:74: note: shadowed declaration is here
   46 | int n,m,s1,s2,s4,s3,sf,k,s5,s6,mx,s7,s8,s9,mx2,res,dem2=0,dem=0,s33,dem3,l,r,mid;
      |                                                                          ^
horses.cpp:103:19: warning: declaration of 'mid' shadows a global declaration [-Wshadow]
  103 |               int mid=l+r>>1;
      |                   ^~~
horses.cpp:46:78: note: shadowed declaration is here
   46 | int n,m,s1,s2,s4,s3,sf,k,s5,s6,mx,s7,s8,s9,mx2,res,dem2=0,dem=0,s33,dem3,l,r,mid;
      |                                                                              ^~~
horses.cpp:103:24: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  103 |               int mid=l+r>>1;
      |                       ~^~
horses.cpp: In function 'void setup()':
horses.cpp:109:15: warning: declaration of 'i' shadows a global declaration [-Wshadow]
  109 |       for(int i=n;i>=1;--i)
      |               ^
horses.cpp:47:6: note: shadowed declaration is here
   47 | int  i,s10,s12;
      |      ^
horses.cpp:110:10: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
  110 |          if(a[i]!=1)
      |          ^~
horses.cpp:112:11: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
  112 |           s.insert(1);
      |           ^
horses.cpp:125:14: warning: conversion from 'long long int' to 'double' may change value [-Wconversion]
  125 |           if(s2>1e9) break;
      |              ^~
horses.cpp: In function 'void setup2()':
horses.cpp:145:14: warning: conversion from 'long long int' to 'double' may change value [-Wconversion]
  145 |           if(s2>1e9) break;
      |              ^~
horses.cpp: In function 'long long int init(long long int, long long int*, long long int*)':
horses.cpp:151:12: warning: declaration of 'i' shadows a global declaration [-Wshadow]
  151 |    for(int i=1;i<=n;i++)
      |            ^
horses.cpp:47:6: note: shadowed declaration is here
   47 | int  i,s10,s12;
      |      ^
horses.cpp:151:4: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  151 |    for(int i=1;i<=n;i++)
      |    ^~~
horses.cpp:153:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  153 |     for(int i=1;i<=n;i++)
      |     ^~~
horses.cpp:153:13: warning: declaration of 'i' shadows a global declaration [-Wshadow]
  153 |     for(int i=1;i<=n;i++)
      |             ^
horses.cpp:47:6: note: shadowed declaration is here
   47 | int  i,s10,s12;
      |      ^
/usr/bin/ld: /tmp/cconGmlp.o: in function `main':
grader.c:(.text.startup+0xaa): undefined reference to `init(int, int*, int*)'
/usr/bin/ld: grader.c:(.text.startup+0x113): undefined reference to `updateX(int, int)'
/usr/bin/ld: grader.c:(.text.startup+0x16d): undefined reference to `updateY(int, int)'
collect2: error: ld returned 1 exit status