답안 #952533

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
952533 2024-03-24T07:38:20 Z guymmk Sterilizing Spray (JOI15_sterilizing) C++14
10 / 100
38 ms 7388 KB
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#define int long long
#define ll long long
#define endl "\n"
#define vi vector<int>
#define vpii vector<pair<int,int> >
#define umap unordered_map
#define uset unordered_set
#define mk make_pair
#define pb push_back
//#define pop pop_back
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define read(x) for (auto& zu: (x)) cin >> zu;
#define F first
#define S second
#define mustawa ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
#define pii pair<int,int>
#define mishari main
const int inf=1e9+7;
void fa(bool ok){ cout << (ok ? "Yes": "No") << "\n";}
void usaco(string s) {
    freopen((s + ".in").c_str(), "r", stdin);
    freopen((s + ".out").c_str(), "w", stdout);
}
int n;
int N=1<<((int)ceil(log2(2e5)));
vi tree(2*N);
int f(int l,int r,int cl=0,int cr=N-1,int i=1){
    if(cl>r||cr<l)return 0;
    else if(cl>=l&&cr<=r){
        return tree[i];
    }int md=(cl+cr)/2;
    return f(l,r,cl,md,i*2)+f(l,r,md+1,cr,i*2+1);
}
void update(int i,int x){
    int j=N+i;
    tree[j]=x;
    while(j/=2){
        tree[j]=tree[j*2]+tree[j*2+1];
    }
}
void solve() {
    int q,k;
    cin>>n>>q>>k;
    for(int i=0;i<n;++i){
        cin>>tree[N+i];
    }
    for(int i=N;--i;){
        tree[i]=tree[i*2]+tree[i*2+1];
    }while(q--){
        int a,b,c;
        cin>>a>>b>>c;
        if(a==1)update(b-1,c);
        else if(a==3) cout<<f(b-1,c-1)<<endl;
    }

}


signed mishari() {
    mustawa;
    //usaco("");
    int t = 1;
    //cin>>t;
    while (t--)solve();
}

Compilation message

sterilizing.cpp: In function 'void usaco(std::string)':
sterilizing.cpp:25:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |     freopen((s + ".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sterilizing.cpp:26:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |     freopen((s + ".out").c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4444 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 4956 KB Output is correct
2 Correct 31 ms 6560 KB Output is correct
3 Correct 27 ms 6492 KB Output is correct
4 Correct 33 ms 6992 KB Output is correct
5 Correct 38 ms 7248 KB Output is correct
6 Correct 38 ms 7384 KB Output is correct
7 Correct 38 ms 7388 KB Output is correct
8 Correct 38 ms 7256 KB Output is correct
9 Correct 35 ms 7248 KB Output is correct
10 Correct 36 ms 7260 KB Output is correct
11 Correct 35 ms 7112 KB Output is correct
12 Correct 35 ms 7252 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 14 ms 4628 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 25 ms 4648 KB Output isn't correct
2 Halted 0 ms 0 KB -