Submission #1006673

# Submission time Handle Problem Language Result Execution time Memory
1006673 2024-06-24T06:56:21 Z modwwe Fish 2 (JOI22_fish2) C++17
13 / 100
4000 ms 10748 KB
//https://www.instagram.com/_modwwe/
#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("avx2,bmi,bmi2")
#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;
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,c;
};
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();
}
ic t[400001];
int a[100001];

void build(int node,int l,int r)
{
     if(l==r) {t[node].a=a[l],t[node].b=l;t[node].c=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|1];
      if(t[node<<1].a>=t[node<<1|1].a)
        t[node]=t[node<<1];
        t[node].c=t[node<<1].c+t[node<<1|1].c;
}
void upd(int node,int l,int r,int l1,int r1,int c)
{
    if(l>r1||r<l1) return;
    if(l>=l1&&r<=r1) {t[node].a=c,t[node].c=c; return;}
int mid=l+r>>1;
upd(node<<1,l,mid,l1,r1,c);
upd(node<<1|1,mid+1,r,l1,r1,c);
t[node]=t[node<<1|1];
if(t[node<<1].a>=t[node<<1|1].a)
    t[node]=t[node<<1];
            t[node].c=t[node<<1].c+t[node<<1|1].c;

}
ib get(int node,int l,int r,int l1,int r1)
{
     if(l>r1||r<l1) return{0,0};
   if(l>=l1&&r<=r1) return {t[node].a,t[node].b};
     int mid=l+r>>1;
      ib ss3=get(node<<1,l,mid,l1,r1);
       ib ss4=get(node<<1|1,mid+1,r,l1,r1);
        if(ss3.a>=ss4.a) return ss3;
        else return ss4;
}
int get_c(int node,int l,int r,int l1,int r1)
{
     if(l>r1||r<l1) return 0;
     if(l>=l1&&r<=r1) return t[node].c;
     int mid=l+r>>1;
      return get_c(node<<1,l,mid,l1,r1)+get_c(node<<1|1,mid+1,r,l1,r1);
}
void calc(int l,int r)
{ s4++;
    if(l>=r) return ;
    ib sx=get(1,1,n,l,r);
 if(sx.b!=l)
 {
     s3=get_c(1,1,n,l,sx.b-1);
     if(s3>=sx.a) calc(l,sx.b-1);
 }
 if(sx.b!=r)
 {
      s3=get_c(1,1,n,sx.b+1,r);
      if(s3>=sx.a) calc(sx.b+1,r);
 }
 return;
}
void phongbeo()
 {
      cin>> n;
      for(int i=1;i<=n;i++)
         cin>>a[i];
       build(1,1,n);
       cin>>m;
        for(int i=1;i<=m;i++)
        {
             cin>>l;
              if(l==1)
              {
                  cin>>l>>r;
                   upd(1,1,n,l,l,r);
              }
              else { cin>>l>>r;
                    s4=0;
                calc(l,r);
                 cout<<s4,down
                }
        }
 }

Compilation message

fish2.cpp:46:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   46 | main()
      | ^~~~
fish2.cpp: In function 'void build(long long int, long long int, long long int)':
fish2.cpp:62:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   62 |      int mid=l+r>>1;
      |              ~^~
fish2.cpp:66:7: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   66 |       if(t[node<<1].a>=t[node<<1|1].a)
      |       ^~
fish2.cpp:68:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   68 |         t[node].c=t[node<<1].c+t[node<<1|1].c;
      |         ^
fish2.cpp: In function 'void upd(long long int, long long int, long long int, long long int, long long int, long long int)':
fish2.cpp:74:10: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   74 | int mid=l+r>>1;
      |         ~^~
fish2.cpp: In function 'ib get(long long int, long long int, long long int, long long int, long long int)':
fish2.cpp:87:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   87 |      int mid=l+r>>1;
      |              ~^~
fish2.cpp: In function 'long long int get_c(long long int, long long int, long long int, long long int, long long int)':
fish2.cpp:97:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   97 |      int mid=l+r>>1;
      |              ~^~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 2 ms 2396 KB Output is correct
11 Correct 4 ms 2532 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 2 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 3 ms 2396 KB Output is correct
20 Correct 7 ms 2396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 9 ms 8796 KB Output is correct
3 Correct 6 ms 9052 KB Output is correct
4 Correct 8 ms 9324 KB Output is correct
5 Correct 6 ms 9052 KB Output is correct
6 Correct 24 ms 9812 KB Output is correct
7 Correct 5 ms 9052 KB Output is correct
8 Correct 21 ms 9808 KB Output is correct
9 Correct 5 ms 8796 KB Output is correct
10 Correct 8 ms 9308 KB Output is correct
11 Correct 7 ms 9068 KB Output is correct
12 Correct 7 ms 9052 KB Output is correct
13 Correct 6 ms 9052 KB Output is correct
14 Correct 14 ms 9436 KB Output is correct
15 Correct 14 ms 9308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 2 ms 2396 KB Output is correct
11 Correct 4 ms 2532 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 2 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 3 ms 2396 KB Output is correct
20 Correct 7 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 9 ms 8796 KB Output is correct
23 Correct 6 ms 9052 KB Output is correct
24 Correct 8 ms 9324 KB Output is correct
25 Correct 6 ms 9052 KB Output is correct
26 Correct 24 ms 9812 KB Output is correct
27 Correct 5 ms 9052 KB Output is correct
28 Correct 21 ms 9808 KB Output is correct
29 Correct 5 ms 8796 KB Output is correct
30 Correct 8 ms 9308 KB Output is correct
31 Correct 7 ms 9068 KB Output is correct
32 Correct 7 ms 9052 KB Output is correct
33 Correct 6 ms 9052 KB Output is correct
34 Correct 14 ms 9436 KB Output is correct
35 Correct 14 ms 9308 KB Output is correct
36 Correct 185 ms 9348 KB Output is correct
37 Correct 85 ms 9052 KB Output is correct
38 Correct 51 ms 9052 KB Output is correct
39 Correct 81 ms 9308 KB Output is correct
40 Correct 51 ms 9052 KB Output is correct
41 Correct 2377 ms 9820 KB Output is correct
42 Correct 3583 ms 9820 KB Output is correct
43 Correct 12 ms 9052 KB Output is correct
44 Correct 13 ms 8852 KB Output is correct
45 Correct 274 ms 9308 KB Output is correct
46 Correct 386 ms 9336 KB Output is correct
47 Correct 35 ms 9052 KB Output is correct
48 Correct 14 ms 9100 KB Output is correct
49 Correct 45 ms 9052 KB Output is correct
50 Correct 1353 ms 9308 KB Output is correct
51 Execution timed out 4058 ms 9436 KB Time limit exceeded
52 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 9 ms 8796 KB Output is correct
3 Correct 6 ms 9052 KB Output is correct
4 Correct 8 ms 9324 KB Output is correct
5 Correct 6 ms 9052 KB Output is correct
6 Correct 24 ms 9812 KB Output is correct
7 Correct 5 ms 9052 KB Output is correct
8 Correct 21 ms 9808 KB Output is correct
9 Correct 5 ms 8796 KB Output is correct
10 Correct 8 ms 9308 KB Output is correct
11 Correct 7 ms 9068 KB Output is correct
12 Correct 7 ms 9052 KB Output is correct
13 Correct 6 ms 9052 KB Output is correct
14 Correct 14 ms 9436 KB Output is correct
15 Correct 14 ms 9308 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Execution timed out 4035 ms 10748 KB Time limit exceeded
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 9 ms 8796 KB Output is correct
3 Correct 6 ms 9052 KB Output is correct
4 Correct 8 ms 9324 KB Output is correct
5 Correct 6 ms 9052 KB Output is correct
6 Correct 24 ms 9812 KB Output is correct
7 Correct 5 ms 9052 KB Output is correct
8 Correct 21 ms 9808 KB Output is correct
9 Correct 5 ms 8796 KB Output is correct
10 Correct 8 ms 9308 KB Output is correct
11 Correct 7 ms 9068 KB Output is correct
12 Correct 7 ms 9052 KB Output is correct
13 Correct 6 ms 9052 KB Output is correct
14 Correct 14 ms 9436 KB Output is correct
15 Correct 14 ms 9308 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Execution timed out 4086 ms 9592 KB Time limit exceeded
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB Output is correct
2 Correct 0 ms 2396 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 2 ms 2396 KB Output is correct
11 Correct 4 ms 2532 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 2 ms 2396 KB Output is correct
17 Correct 1 ms 2396 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 3 ms 2396 KB Output is correct
20 Correct 7 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 9 ms 8796 KB Output is correct
23 Correct 6 ms 9052 KB Output is correct
24 Correct 8 ms 9324 KB Output is correct
25 Correct 6 ms 9052 KB Output is correct
26 Correct 24 ms 9812 KB Output is correct
27 Correct 5 ms 9052 KB Output is correct
28 Correct 21 ms 9808 KB Output is correct
29 Correct 5 ms 8796 KB Output is correct
30 Correct 8 ms 9308 KB Output is correct
31 Correct 7 ms 9068 KB Output is correct
32 Correct 7 ms 9052 KB Output is correct
33 Correct 6 ms 9052 KB Output is correct
34 Correct 14 ms 9436 KB Output is correct
35 Correct 14 ms 9308 KB Output is correct
36 Correct 185 ms 9348 KB Output is correct
37 Correct 85 ms 9052 KB Output is correct
38 Correct 51 ms 9052 KB Output is correct
39 Correct 81 ms 9308 KB Output is correct
40 Correct 51 ms 9052 KB Output is correct
41 Correct 2377 ms 9820 KB Output is correct
42 Correct 3583 ms 9820 KB Output is correct
43 Correct 12 ms 9052 KB Output is correct
44 Correct 13 ms 8852 KB Output is correct
45 Correct 274 ms 9308 KB Output is correct
46 Correct 386 ms 9336 KB Output is correct
47 Correct 35 ms 9052 KB Output is correct
48 Correct 14 ms 9100 KB Output is correct
49 Correct 45 ms 9052 KB Output is correct
50 Correct 1353 ms 9308 KB Output is correct
51 Execution timed out 4058 ms 9436 KB Time limit exceeded
52 Halted 0 ms 0 KB -