結果

問題 No.1558 Derby Live
ユーザー 👑 potato167potato167
提出日時 2021-06-25 21:38:10
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 235 ms / 2,000 ms
コード長 2,690 bytes
コンパイル時間 3,032 ms
コンパイル使用メモリ 210,380 KB
実行使用メモリ 29,696 KB
最終ジャッジ日時 2023-09-07 14:18:47
合計ジャッジ時間 11,612 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 235 ms
29,532 KB
testcase_01 AC 207 ms
29,532 KB
testcase_02 AC 22 ms
17,436 KB
testcase_03 AC 174 ms
29,604 KB
testcase_04 AC 91 ms
17,388 KB
testcase_05 AC 106 ms
17,512 KB
testcase_06 AC 162 ms
21,472 KB
testcase_07 AC 26 ms
21,360 KB
testcase_08 AC 155 ms
17,388 KB
testcase_09 AC 167 ms
21,344 KB
testcase_10 AC 166 ms
21,344 KB
testcase_11 AC 170 ms
21,348 KB
testcase_12 AC 171 ms
21,404 KB
testcase_13 AC 180 ms
25,704 KB
testcase_14 AC 183 ms
25,632 KB
testcase_15 AC 187 ms
25,640 KB
testcase_16 AC 194 ms
25,632 KB
testcase_17 AC 200 ms
29,656 KB
testcase_18 AC 206 ms
29,648 KB
testcase_19 AC 211 ms
29,532 KB
testcase_20 AC 214 ms
29,652 KB
testcase_21 AC 202 ms
29,664 KB
testcase_22 AC 210 ms
29,584 KB
testcase_23 AC 214 ms
29,532 KB
testcase_24 AC 205 ms
29,660 KB
testcase_25 AC 213 ms
29,656 KB
testcase_26 AC 216 ms
29,548 KB
testcase_27 AC 202 ms
29,656 KB
testcase_28 AC 213 ms
29,656 KB
testcase_29 AC 218 ms
29,600 KB
testcase_30 AC 206 ms
29,532 KB
testcase_31 AC 212 ms
29,696 KB
testcase_32 AC 216 ms
29,660 KB
testcase_33 AC 22 ms
17,500 KB
testcase_34 AC 23 ms
17,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
using std::cout;
using std::cin;
using std::endl;
using ll=long long;
using ld=long double;
ll I=1167167167167167167;
ll Q=1e9+7;
#define rep(i,a) for (ll i=0;i<a;i++)
template<class T> using _pq = priority_queue<T, vector<T>, greater<T>>;
template<class T> ll LB(vector<T> &v,T a){return lower_bound(v.begin(),v.end(),a)-v.begin();}
template<class T> ll UB(vector<T> &v,T a){return upper_bound(v.begin(),v.end(),a)-v.begin();}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}else return 0;}
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}else return 0;}
template<class T> void So(vector<T> &v) {sort(v.begin(),v.end());}
template<class T> void Sore(vector<T> &v) {sort(v.begin(),v.end(),[](T x,T y){return x>y;});}
template<class T> void print_tate(vector<T> &v) {rep(i,v.size()) cout<<v[i]<<"\n";}
void yneos(bool a){if(a) cout<<"Yes"<<"\n"; else cout<<"No"<<"\n";}

using F=vector<int>;
F e={};//単位元
int MAX_N=131072;
std::vector<F> segment(MAX_N*2-1);

F segment_function(F a,F b){
	int n=a.size();
    vector<int> p(n);
	rep(i,n){
		p[i]=b[a[i]];
	}
	return p;
}
void pu_fanction(F &a,F b){
    a=b;
}

namespace po167{
F get(int k){return segment[k+MAX_N-1];}
F qu_sub(int a,int b,int l,int r,int k){
    if(b<=l||r<=a) return e;
    if(a<=l&&r<=b) return segment[k];
    else{
        F X=qu_sub(a,b,l,(r+l)/2,k*2+1);
        F Y=qu_sub(a,b,(l+r)/2,r,k*2+2);
        return segment_function(X,Y);
    }
}
F qu(int a,int b){return qu_sub(a,b,0,MAX_N,0);}
// get(k)=a
void replace(int k,F a){
    k+=(MAX_N-1);
    segment[k]=a;
    while(k>0){
        k--;
        k/=2;
        segment[k]=segment_function(segment[k*2+1],segment[k*2+2]);
    } 
}
//get(k) ◯ a
void pu(int k,F a){
    k+=(MAX_N-1);
    pu_fanction(segment[k],a);
    while(k>0){
        k--;
        k/=2;
        segment[k]=segment_function(segment[k*2+1],segment[k*2+2]);
    }
}
};
using namespace po167;


//おちこんだりもしたけれど、私はげんきです。
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int N,M,T;
	cin>>N>>M>>T;
	rep(i,N) e.push_back(i);
	rep(i,MAX_N*2-1) segment[i]=e;
	rep(i,T){
		int t;
		cin>>t;
		if(t==1){
			vector<int> q(N);
			int x;
			cin>>x;
			rep(i,N) cin>>q[i],q[i]-=1;
			pu(x-1,q);
		}
		if(t==2){
			vector<int> ans(N);
			int x;
			cin>>x;
			auto q=qu(0,x);
			rep(i,N){
				ans[q[i]]=i;
			}
			rep(i,N){
				if(i!=0) cout<<" ";
				cout<<ans[i]+1;
			}
			cout<<"\n";
		}
		if(t==3){
			int l,r;
			cin>>l>>r;
			auto q=qu(l-1,r);
			int ans=0;
			rep(i,N) ans+=abs(q[i]-i);
			cout<<ans<<"\n";
		}
	}
	return 0;
}
0