結果
| 問題 |
No.1558 Derby Live
|
| コンテスト | |
| ユーザー |
srjywrdnprkt
|
| 提出日時 | 2023-06-12 23:41:51 |
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 2,504 bytes |
| コンパイル時間 | 2,499 ms |
| コンパイル使用メモリ | 130,436 KB |
| 最終ジャッジ日時 | 2025-02-14 02:10:54 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function 'S e()':
main.cpp:80:12: error: reference to 'identity' is ambiguous
80 | return identity;
| ^~~~~~~~
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/bits/iterator_concepts.h:38,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/bits/stl_iterator_base_types.h:71,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/bits/stl_construct.h:61,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/bits/char_traits.h:46,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/ios:40,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/ostream:38,
from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/iostream:39,
from main.cpp:1:
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/bits/ranges_cmp.h:47:10: note: candidates are: 'struct std::identity'
47 | struct identity
| ^~~~~~~~
main.cpp:71:3: note: 'S identity'
71 | S identity;
| ^~~~~~~~
main.cpp: In function 'int main()':
main.cpp:88:5: error: reference to 'identity' is ambiguous
88 | identity.resize(N);
| ^~~~~~~~
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/bits/ranges_cmp.h:47:10: note: candidates are: 'struct std::identity'
47 | struct identity
| ^~~~~~~~
main.cpp:71:3: note: 'S identity'
71 | S identity;
| ^~~~~~~~
main.cpp:89:29: error: reference to 'identity' is ambiguous
89 | for (int i=0; i<N; i++) identity[i] = i;
| ^~~~~~~~
/home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.4.0/include/c++/12/bits/ranges_cmp.h:47:10: note: candidates are: 'struct std::identity'
47 | struct identity
| ^~~~~~~~
main.cpp:71:3: note: 'S
ソースコード
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
#include <complex>
using namespace std;
using ll = long long;
template<class S, S (*op)(S, S), S (*e)()>struct SegTree {
vector<S> seg;
int N = 1;
SegTree (ll n) : SegTree(vector<S>(n, e())) {}
SegTree (const vector<S> &v){
ll n = v.size();
while (N < n) N *= 2;
seg.resize(N*2-1, e());
for (ll i=0; i<n; i++) seg[i+N-1] = v[i];
for (ll i=N-2; i>=0; i--){
seg[i] = op(seg[i*2+1], seg[i*2+2]);
}
}
void set(int loc, S val){
loc += N-1;
seg[loc] = val;
while (loc != 0){
loc = (loc-1)/2;
seg[loc] = op(seg[loc*2+1], seg[loc*2+2]);
}
}
//op(a[l], ..., a[r])
S prod (int l, int r) const{
return _prod(l, r, 0, 0, N-1);
}
S all_prod() const{
return seg[0];
}
S _prod (int l, int r, int idx, int bitl, int bitr) const{
if (r < bitl || l > bitr) return e();
if (l <= bitl && bitr <= r) return seg[idx];
ll bitm = (bitl+bitr)/2;
return op(_prod(l, r, idx*2+1, bitl, bitm), _prod(l, r, idx*2+2, bitm+1, bitr));
}
S get (int i) const{
return seg[i+N-1];
}
void show() const{
for (int i=N-1; i<N*2-1; i++) cout << seg[i] << " ";
cout << endl;
}
};
//RMQ
int N;
using S = vector<int>;
S identity;
S op(S a, S b){
S c(N);
for (int i=0; i<N; i++) c[i] = b[a[i]];
return c;
}
S e(){
return identity;
}
//
int main(){
int M, q, t, x, y, ans;
cin >> N >> M >> q;
identity.resize(N);
for (int i=0; i<N; i++) identity[i] = i;
SegTree<S, op, e> tree(M+1);
S P(N), Q(N);
while(q){
q--;
cin >> t;
if (t == 1){
cin >> x;
for (int i=0; i<N; i++){
cin >> P[i]; P[i]--;
}
tree.set(x, P);
}
else if (t == 2){
cin >> x;
P = tree.prod(0, x);
for (int i=0; i<N; i++) Q[P[i]] = i+1;
for (int i=0; i<N; i++) cout << Q[i] << " ";
cout << endl;
}
else{
cin >> x >> y;
ans = 0;
P = tree.prod(x, y);
for (int i=0; i<N; i++) ans += abs(P[i]-i);
cout << ans << endl;
}
}
return 0;
}
srjywrdnprkt