結果

問題 No.1386 Range add Simulation
ユーザー 👑 kmjpkmjp
提出日時 2021-02-11 12:48:19
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 2,083 bytes
コンパイル時間 3,866 ms
コンパイル使用メモリ 205,180 KB
実行使用メモリ 29,412 KB
最終ジャッジ日時 2023-09-25 01:54:35
合計ジャッジ時間 106,911 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 4 ms
4,376 KB
testcase_02 AC 4 ms
4,376 KB
testcase_03 AC 4 ms
4,376 KB
testcase_04 AC 4 ms
4,376 KB
testcase_05 AC 4 ms
4,380 KB
testcase_06 AC 762 ms
15,216 KB
testcase_07 AC 758 ms
15,640 KB
testcase_08 AC 768 ms
15,208 KB
testcase_09 AC 760 ms
15,864 KB
testcase_10 AC 763 ms
15,908 KB
testcase_11 TLE -
testcase_12 TLE -
testcase_13 TLE -
testcase_14 TLE -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
testcase_20 TLE -
testcase_21 TLE -
testcase_22 TLE -
testcase_23 TLE -
testcase_24 TLE -
testcase_25 TLE -
testcase_26 TLE -
testcase_27 TLE -
testcase_28 TLE -
testcase_29 TLE -
testcase_30 TLE -
testcase_31 TLE -
testcase_32 TLE -
testcase_33 TLE -
testcase_34 TLE -
testcase_35 AC 2 ms
4,376 KB
testcase_36 AC 5 ms
4,376 KB
testcase_37 AC 7 ms
4,376 KB
testcase_38 AC 6 ms
4,376 KB
testcase_39 AC 5 ms
4,380 KB
testcase_40 TLE -
testcase_41 TLE -
testcase_42 TLE -
testcase_43 TLE -
testcase_44 TLE -
testcase_45 TLE -
testcase_46 TLE -
testcase_47 TLE -
testcase_48 TLE -
testcase_49 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------

int N,Q;
ll V[101010];
ll A[101010];
ll B[101010];


vector<vector<int>> R;

void dfs(int cur,ll v) {
	if(v==0) return;
	if(v/2) {
		dfs(cur,v/2);
		B[cur]*=2;
		R.push_back({3,cur,cur});
	}
	if(v%2) {
		if(v>0) R.push_back({1,cur}), B[cur]++;
		else R.push_back({2,cur}), B[cur]--;
	}
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>Q;
	FOR(i,Q) {
		cin>>x>>y;
		if(x==1) {
			if(y==1) {
				V[1]++;
				V[2]+=3;
				V[3]+=2;
			}
			else if(y==2) {
				V[2]++;
				V[3]+=2;
			}
			else {
				V[y]++;
				V[y+1]++;
			}
			for(j=y;j<=N;j++) A[j]+=1LL*(j-y+1)*(j-y+1);
		}
		else {
			V[1]+=1LL*y*y;
			V[2]-=2*y-1;
			V[3]+=2;
			V[y+2]--;
			V[y+3]--;
			for(j=1;j<=y;j++) A[j]+=1LL*(j-y+1)*(j-y+1);
		}
	}
	//cout<<"S1 "; FOR(i,N) cout<<A[i+1]<<" "; cout<<endl;
	for(i=1;i<=N;i++) dfs(i,V[i]);
	//cout<<"S1 ";FOR(i,N) cout<<B[i+1]<<" ";	cout<<endl;
	for(i=3;i<N;i++) R.push_back({3,i+1,i}), B[i+1]+=B[i];
	//cout<<"S1 ";FOR(i,N) cout<<B[i+1]<<" ";	cout<<endl;
	for(i=2;i<N;i++) R.push_back({3,i+1,i}), B[i+1]+=B[i];
	//cout<<"S1 ";FOR(i,N) cout<<B[i+1]<<" ";	cout<<endl;
	for(i=1;i<N;i++) R.push_back({3,i+1,i}), B[i+1]+=B[i];
	//cout<<"S1 ";FOR(i,N) cout<<B[i+1]<<" ";	cout<<endl;
	cout<<R.size()<<endl;
	FORR(r,R) {
		FORR(v,r) cout<<v<<" ";
		cout<<endl;
	}
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0