結果
| 問題 | No.3116 More and more teleporter |
| コンテスト | |
| ユーザー |
Yu_212
|
| 提出日時 | 2025-04-19 09:33:55 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,879 bytes |
| 記録 | |
| コンパイル時間 | 1,865 ms |
| コンパイル使用メモリ | 323,156 KB |
| 最終ジャッジ日時 | 2026-07-09 22:10:45 |
| 合計ジャッジ時間 | 2,635 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/bits/stl_algobase.h:76,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/algorithm:62,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/x86_64-pc-linux-gnu/bits/stdc++.h:53,
from main.cpp:1:
/home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/bit: In instantiation of 'constexpr int std::__countl_zero(_Tp) [with _Tp = int]':
/home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/bit:349:55: required from 'constexpr _Tp std::__bit_ceil(_Tp) [with _Tp = int]'
349 | auto __shift_exponent = _Nd - std::__countl_zero((_Tp)(__x - 1u));
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
main.cpp:23:27: required from 'SegTree<T>::SegTree(F, T, int) [with T = long long int; F = std::function<long long int(long long int, long long int)>]'
23 | n = max(__bit_ceil(num), 1);
| ~~~~~~~~~~^~~~~
main.cpp:52:67: required from here
52 | SegTree<ll> segL([&](ll a, ll b) { return min(a, b); }, inf, N);
| ^
/home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/bit:209:29: error: argument 1 in call to function '__builtin_clzg' has signed type
209 | return __builtin_clzg(__x, _Nd);
| ^~~
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int iinf = 1e9;
const ll inf = 1e18;
template<typename T>
ostream& operator<<(ostream &o, vector<T> v) {
for (int i = 0; i < v.size(); i++)
o << v[i] << (i+1<v.size()?" ":"");
return o;
}
template <typename T>
struct SegTree {
using F = function<T(T, T)>;
int n;
F f;
T ti;
vector<T> dat;
SegTree() {}
SegTree(F f, T ti,int num) : f(f), ti(ti) {
n = max(__bit_ceil(num), 1);
dat.assign(n << 1, ti);
}
SegTree(F f,T ti,vector<T>&v):SegTree(f,ti,v.size()){
for (int i = 0; i < v.size(); i++)
dat[n + i] = v[i];
for(int i=n-1;i;i--) dat[i]=f(dat[i*2], dat[i*2+1]);
}
void set_val(int k, T x) {
dat[k += n] = x;
while(k >>= 1) dat[k] = f(dat[k*2], dat[k*2+1]);
}
T query(int a, int b) {
if (a >= b) return ti;
T vl = ti, vr = ti;
for (int l=a+n, r=b+n; l<r; l>>=1, r>>=1) {
if (l & 1) vl = f(vl, dat[l++]);
if (r & 1) vr = f(dat[--r], vr);
}
return f(vl, vr);
}
};
struct Edge { int to; ll cost; };
int main() {
cin.tie(0)->sync_with_stdio(false);
int N, Q;
cin >> N >> Q;
SegTree<ll> segL([&](ll a, ll b) { return min(a, b); }, inf, N);
SegTree<ll> segR([&](ll a, ll b) { return min(a, b); }, inf, N);
while(Q--){
int type, x;
cin >> type >> x;
x--;
if(type == 1){
ll ans = x;
ll t1 = segL.query(0, x) + x;
ll t2 = segR.query(x, N) - x;
ans = min({ans, t1, t2});
cout << ans << "\n";
} else {
ll c;
cin >> c;
segL.set_val(x, min(segL.query(x,x+1), c - x));
segR.set_val(x, min(segR.query(x,x+1), c + x));
}
}
return 0;
}
Yu_212