結果

問題 No.230 Splarraay スプラレェーイ
ユーザー 沙耶花沙耶花
提出日時 2021-11-16 23:10:08
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,750 bytes
コンパイル時間 4,442 ms
コンパイル使用メモリ 252,640 KB
最終ジャッジ日時 2025-01-25 18:52:34
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 5 WA * 10 TLE * 2
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:24:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   24 |                 scanf("%d %d %d",&x,&l,&r);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~

ソースコード

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