답안 #1003215

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1003215 2024-06-20T07:53:07 Z modwwe Sterilizing Spray (JOI15_sterilizing) C++17
100 / 100
137 ms 7464 KB
///https://www.instagram.com/_modwwe/
#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 inf=1e18;
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();
}
ib t[400001];
 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].b=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].a=t[node<<1].a+t[node<<1|1].a;
 t[node].b=max(t[node<<1].b,t[node<<1|1].b);
}
void upd2(int node,int l,int r,int l1,int r1)
 {
      if(l>r1||r<l1||t[node].b==0) return ;
     if(l==r){t[node].a/=k,t[node].b/=k; return;}
     int mid=l+r>>1;
      upd2(node<<1,l,mid,l1,r1);
      upd2(node<<1|1,mid+1,r,l1,r1);
       t[node].b=max(t[node<<1].b,t[node<<1|1].b);
        t[node].a=t[node<<1].a+t[node<<1|1].a;

 }
int get(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].a;
        int mid=l+r>>1;
         return get(node<<1,l,mid,l1,r1)+get(node<<1|1,mid+1,r,l1,r1);
 }
void phongbeo()
{
 cin>>n>>m>>k;
  for(int i=1;i<=n;i++)
  {
        cin>>l;
         upd(1,1,n,i,i,l);
  }
  for(int i=1;i<=m;i++)
  {
       cin>>l;
        if(l==1)
        {
              cin>>l>>r;
               upd(1,1,n,l,l,r);
        }
        else if(l==2)
        {
 cin>>l>>r;
 if(k!=1)
  upd2(1,1,n,l,r);
        }
        else
        {
             cin>>l>>r;
              cout<<get(1,1,n,l,r),down
        }
  }
}

Compilation message

sterilizing.cpp:45:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   45 | main()
      | ^~~~
sterilizing.cpp: In function 'void upd(long long int, long long int, long long int, long long int, long long int, long long int)':
sterilizing.cpp:63:19: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   63 |          int mid=l+r>>1;
      |                  ~^~
sterilizing.cpp: In function 'void upd2(long long int, long long int, long long int, long long int, long long int)':
sterilizing.cpp:73:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   73 |      int mid=l+r>>1;
      |              ~^~
sterilizing.cpp: In function 'long long int get(long long int, long long int, long long int, long long int, long long int)':
sterilizing.cpp:84:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   84 |         int mid=l+r>>1;
      |                 ~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 472 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 2 ms 584 KB Output is correct
5 Correct 3 ms 616 KB Output is correct
6 Correct 2 ms 616 KB Output is correct
7 Correct 2 ms 604 KB Output is correct
8 Correct 2 ms 484 KB Output is correct
9 Correct 3 ms 604 KB Output is correct
10 Correct 2 ms 604 KB Output is correct
11 Correct 3 ms 624 KB Output is correct
12 Correct 2 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 4784 KB Output is correct
2 Correct 32 ms 4444 KB Output is correct
3 Correct 33 ms 6492 KB Output is correct
4 Correct 43 ms 6864 KB Output is correct
5 Correct 50 ms 7464 KB Output is correct
6 Correct 56 ms 7320 KB Output is correct
7 Correct 46 ms 7332 KB Output is correct
8 Correct 43 ms 7248 KB Output is correct
9 Correct 42 ms 7200 KB Output is correct
10 Correct 52 ms 7348 KB Output is correct
11 Correct 47 ms 7248 KB Output is correct
12 Correct 48 ms 7252 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 1116 KB Output is correct
2 Correct 16 ms 2652 KB Output is correct
3 Correct 15 ms 2908 KB Output is correct
4 Correct 35 ms 2504 KB Output is correct
5 Correct 51 ms 5864 KB Output is correct
6 Correct 51 ms 5968 KB Output is correct
7 Correct 46 ms 5972 KB Output is correct
8 Correct 51 ms 5968 KB Output is correct
9 Correct 45 ms 5712 KB Output is correct
10 Correct 47 ms 5716 KB Output is correct
11 Correct 47 ms 5724 KB Output is correct
12 Correct 43 ms 5708 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 61 ms 4176 KB Output is correct
2 Correct 57 ms 4176 KB Output is correct
3 Correct 63 ms 3704 KB Output is correct
4 Correct 68 ms 3408 KB Output is correct
5 Correct 83 ms 7248 KB Output is correct
6 Correct 101 ms 7248 KB Output is correct
7 Correct 84 ms 7248 KB Output is correct
8 Correct 107 ms 7184 KB Output is correct
9 Correct 99 ms 6992 KB Output is correct
10 Correct 114 ms 7124 KB Output is correct
11 Correct 112 ms 7124 KB Output is correct
12 Correct 137 ms 7108 KB Output is correct