結果

問題 No.230 Splarraay スプラレェーイ
ユーザー 沙耶花
提出日時 2021-11-16 22:41:18
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 618 bytes
コンパイル時間 4,156 ms
コンパイル使用メモリ 251,448 KB
最終ジャッジ日時 2025-01-25 18:50:24
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13 TLE * 4
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:20:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   20 |                 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


int main(){
	
	int N,Q;
	cin>>N>>Q;
	
	vector<int> a(N,0);
	int A=0,B=0;
	rep(_,Q){
		int x,l,r;
		scanf("%d %d %d",&x,&l,&r);
		
		
		if(x==0){
			vector<int> c(3,0);
			for(int i=l;i<=r;i++)c[a[i]]++;
			if(c[1]>c[2])A += c[1];
			if(c[1]<c[2])B += c[2];
		}
		else{
			for(int i=l;i<=r;i++)a[i] = x;
		}
	}
	
	rep(i,N){
		if(a[i]==1)A++;
		if(a[i]==2)B++;
	}
	
	cout<<A<<' '<<B<<endl;
	
	return 0;
}
0