結果
| 問題 |
No.2942 Sigma Music Game Level Problem
|
| コンテスト | |
| ユーザー |
zazaboon
|
| 提出日時 | 2024-10-18 22:52:03 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1,721 ms / 6,000 ms |
| コード長 | 8,349 bytes |
| コンパイル時間 | 2,767 ms |
| コンパイル使用メモリ | 172,128 KB |
| 実行使用メモリ | 14,336 KB |
| 最終ジャッジ日時 | 2024-11-14 23:04:04 |
| 合計ジャッジ時間 | 20,055 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 |
ソースコード
//solve atcoder problem
//memo:for (const auto &e : e) {
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define foreach(e, m) for (const auto &(e) : (m))
#define ll long long
#define ldf long double
#define flout std::fixed << std::setprecision(15) <<
#define txt freopen("wormsort.in", "r", stdin), freopen("wormsort.out", "w", stdout);
#define dmap unordered_map
#define dmin(x) *min_element(begin(x), end(x))
#define dmax(x) *max_element(begin(x), end(x))
#define huge 4e18
#define intbig (ll)2e9
#define vec2(t) vector<vector<t>>
#define vec3(t) vector<vector<vector<t>>>
#define bit(x) (1LL << (x))
#define r_up(x, y) (((x) + (y) - 1) / (y))
#define jun_end(a) } while (next_permutation(a.begin(), a.end()));
#define pll pair<ll, ll>
// #define __popcnt __builtin_popcount
// #define __popcnt64 __builtin_popcountll
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <array>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <sstream>
#include <map>
#include <random>
#include <unordered_map>
#include <cassert>
#include <bit>
#include <cstdint>
using namespace std;
const ll MOD = 1e9 + 7;
const ll MOD9 = 998244353;
vector<ll> inp() { string input;getline(cin,input);stringstream ss(input);vector<ll> result;ll number;while(ss >> number) { result.push_back(number); }return result; }
map<ll,ll> tally(vector<ll>& a) { map<ll,ll> h;for(ll i = 0; i < a.size(); i++) { h[a[i]]++; }return h; }
ll gcd(ll a,ll b) { if(b == 0) { return a; }return gcd(b,a % b); }
ll modpow(ll a,ll n,ll mod) { ll res = 1;while(n > 0) { if(n & 1) { res = res * a % mod; }a = a * a % mod;n >>= 1; }return res; }
ll lcm(ll a,ll b) { return a / gcd(a,b) * b; }
ll kaijo(ll n,ll mod) { ll res = 1;for(ll i = 1; i <= n; i++) { res *= i;res %= mod; }return res; }
ll comb(ll n,ll k,ll mod) { ll res = 1;for(ll i = 1; i <= k; i++) { res *= n - i + 1;res %= mod;res *= modpow(i,mod - 2,mod);res %= mod; }return res; }
ll isqrt(ll n,bool f = false) { if(n == 1) { return 1; }ll a = sqrtl(n + 1);if(a * a > n) { a--; }if(f) { if(a * a != n) { return a + 1; } }return a; }
template<typename TTM>
TTM sum(vector<TTM> a) { TTM sum = 0;for(ll i = 0; i < a.size(); i++) { sum += a[i]; }return sum; }
vector<vector<ll>> matrix_mul(vector<vector<ll>>& a,vector<vector<ll>>& b,ll mod) { ll n = a.size();ll m = a[0].size();ll l = b[0].size();vector<vector<ll>> c(n,vector<ll>(l,0));for(ll i = 0; i < n; i++) { for(ll j = 0; j < l; j++) { for(ll k = 0; k < m; k++) { c[i][j] += a[i][k] * b[k][j];c[i][j] %= mod; } } }return c; }
vector<ldf> inpf() { string input;getline(cin,input);stringstream ss(input);vector<ldf> result;ldf number;while(ss >> number) { result.push_back(number); }return result; }
ll s_maxop(ll a,ll b) { return max(b,a); }
ll s_maxe() { return 0; }
template<typename TM>
vector<TM> csum(vector<TM>& a,bool f = false) { vector<TM> res(a.size() + 1,0);for(ll i = 0; i < a.size(); i++) { res[i + 1] = res[i] + a[i]; }if(f) { res.erase(res.begin()); }return res; }
template<typename TMR>
vector<TMR> colum(vector<vector<TMR>>& a,ll col) { ll n = a.size();vector<TMR> res(0);for(ll i = 0; i < n; i++) { res.push_back(res[i][col]); }return res; }
template<typename TRR>
vector<TRR> p_col(vector<pair<TRR,TRR>>& a,bool f = true) { ll n = a.size();vector<TRR> res(0);for(ll i = 0; i < n; i++) { if(f) { res.push_back(a[i].first); } else { res.push_back(a[i].second); } }return res; }
/*
ll dfs(ll x,ll prev) {
rep(i, links[x].size()) {
ll y = links[x][i];
if(y == prev) {
continue;
}
dfs(y,x);
}
return 0LL;
}
*/
ll n,x;
vec2(ll) datas;
#include <cassert>
#include <vector>
#include <type_traits>
namespace internal {
#ifndef _MSC_VER
template <class T>
using is_signed_int128 =
typename std::conditional<std::is_same<T,__int128_t>::value ||
std::is_same<T,__int128>::value,
std::true_type,
std::false_type>::type;
template <class T>
using is_unsigned_int128 =
typename std::conditional<std::is_same<T,__uint128_t>::value ||
std::is_same<T,unsigned __int128>::value,
std::true_type,
std::false_type>::type;
template <class T>
using make_unsigned_int128 =
typename std::conditional<std::is_same<T,__int128_t>::value,
__uint128_t,
unsigned __int128>;
template <class T>
using is_integral = typename std::conditional<std::is_integral<T>::value ||
is_signed_int128<T>::value ||
is_unsigned_int128<T>::value,
std::true_type,
std::false_type>::type;
template <class T>
using is_signed_int = typename std::conditional<(is_integral<T>::value&&
std::is_signed<T>::value) ||
is_signed_int128<T>::value,
std::true_type,
std::false_type>::type;
template <class T>
using is_unsigned_int =
typename std::conditional<(is_integral<T>::value&&
std::is_unsigned<T>::value) ||
is_unsigned_int128<T>::value,
std::true_type,
std::false_type>::type;
template <class T>
using to_unsigned = typename std::conditional<
is_signed_int128<T>::value,
make_unsigned_int128<T>,
typename std::conditional<std::is_signed<T>::value,
std::make_unsigned<T>,
std::common_type<T>>::type>::type;
#else
template <class T> using is_integral = typename std::is_integral<T>;
template <class T>
using is_signed_int =
typename std::conditional<is_integral<T>::value&& std::is_signed<T>::value,
std::true_type,
std::false_type>::type;
template <class T>
using is_unsigned_int =
typename std::conditional<is_integral<T>::value&&
std::is_unsigned<T>::value,
std::true_type,
std::false_type>::type;
template <class T>
using to_unsigned = typename std::conditional<is_signed_int<T>::value,
std::make_unsigned<T>,
std::common_type<T>>::type;
#endif
template <class T>
using is_signed_int_t = std::enable_if_t<is_signed_int<T>::value>;
template <class T>
using is_unsigned_int_t = std::enable_if_t<is_unsigned_int<T>::value>;
template <class T> using to_unsigned_t = typename to_unsigned<T>::type;
} // namespace internal
// Reference: https://en.wikipedia.org/wiki/Fenwick_tree
template <class T> struct fenwick_tree {
using U = internal::to_unsigned_t<T>;
public:
fenwick_tree() : _n(0) {}
fenwick_tree(int n) : _n(n),data(n) {}
void add(int p,T x) {
assert(0 <= p && p < _n);
p++;
while(p <= _n) {
data[p - 1] += U(x);
p += p & -p;
}
}
T sum(int l,int r) {
assert(0 <= l && l <= r && r <= _n);
return sum(r) - sum(l);
}
private:
int _n;
std::vector<U> data;
U sum(int r) {
U s = 0;
while(r > 0) {
s += data[r - 1];
r -= r & -r;
}
return s;
}
};
vector<vector<ll>> links;
// must use int not ll
// intを使わないように注意!
int main()
{
ll n,q,l;
cin >> n >> q >> l;cin.ignore();
fenwick_tree<ll> fw(200001);
fenwick_tree<ll> cw(200001);
vector<ll> a(n);
rep(i, n) {
cin >> a[i];
cw.add(a[i],1);
fw.add(a[i],a[i]);
}
bool flag = true;
rep(i,q) {
ll t;
cin >> t;
if(t == 1) {
ll l;
cin >> l;
cw.add(l,1);
fw.add(l,l);
}else if(t == 2) {
ll l,r;
cin >> l >> r;
ll count;
ll sum;
count = cw.sum(l,r+1);
sum = fw.sum(l,r+1);
flag = false;
cout << count << " " << sum << endl;
}
else {
ll m;
cin >> m;
}
}
if(flag) {
cout << "Not Found!" << endl;
}
return 0;
}
/*test case
1
2 5
0 5
5
*/
zazaboon