結果

問題 No.230 Splarraay スプラレェーイ
ユーザー 沙耶花沙耶花
提出日時 2021-11-16 23:10:08
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,750 bytes
コンパイル時間 4,255 ms
コンパイル使用メモリ 261,124 KB
実行使用メモリ 8,040 KB
最終ジャッジ日時 2023-08-23 04:55:38
合計ジャッジ時間 11,672 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 WA -
testcase_10 AC 42 ms
4,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 TLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint1000000007;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000001
#define sz 400

int main(){
	
	int N,Q;
	cin>>N>>Q;
	
	vector<int> a(N,0);
	int cnt = (N+sz-1)/sz;
	vector<int> lazy(cnt,0);
	vector<int> Ac(cnt,0),Bc(cnt,0);
	
	int A=0,B=0;
	rep(_,Q){
		int x,l,r;
		scanf("%d %d %d",&x,&l,&r);
		
		
		if(x==0){
			int AA = 0,BB = 0;
			while(l<=r){
				
				if(l%sz==0 || l+sz>r){
					int rr;
					rr = ((l+sz)/sz)*sz-1;
					if(rr>r)rr = r;
					
					for(int i=l;i<=rr;i++){
						if(lazy[i/sz]==1||(lazy[i/sz]==0&&a[i]==1))AA++;
						if(lazy[i/sz]==2||(lazy[i/sz]==0&&a[i]==2))BB++;
					}
					l = rr+1;
				}
				else{
					AA += Ac[l/sz];
					BB += Bc[l/sz];
					l += sz;
				}
			}
			if(AA>BB)A += AA;
			if(AA<BB)B += BB;
		}
		else{
			while(l<=r){
				
				if(l%sz!=0 || l+sz>r){
					int rr;
					rr = ((l+sz)/sz)*sz-1;
					if(rr>r)rr = r;
					
					if(lazy[l/sz]!=0){
						for(int i=(l/sz)*sz;i<min(N,(l/sz)*sz+sz);i++){
							a[i] = lazy[l/sz];
						}
						lazy[l/sz] = 0;
					}
					//cout<<l<<','<<rr<<endl;
					for(int i=l;i<=rr;i++)a[i] = x;
					Ac[l/sz] = 0;
					Bc[l/sz] = 0;
					for(int i=(l/sz)*sz;i<min(N,(l/sz)*sz+sz);i++){
						if(a[i]==1)Ac[l/sz]++;
						if(a[i]==2)Bc[l/sz]++;
					}
					l = rr+1;
				}
				else{
					//cout<<l/sz<<endl;
					lazy[l/sz] = x;
					Ac[l/sz] = 0;
					Bc[l/sz] = 0;
					int t = min(N,l+sz) - l;
					//cout<<t<<endl;
					if(x==1)Ac[l/sz] = t;
					else Bc[l/sz] = t;
					l += sz;
				}
			}
		}
	}
	
	rep(i,cnt){
	///	cout<<Ac[i]<<','<<Bc[i]<<endl;
		A += Ac[i];
		B += Bc[i];
	}
	
	cout<<A<<' '<<B<<endl;
	
	return 0;
}
0