結果

問題 No.945 YKC饅頭
ユーザー ransewhaleransewhale
提出日時 2019-12-08 05:26:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 256 ms / 2,000 ms
コード長 1,444 bytes
コンパイル時間 4,705 ms
コンパイル使用メモリ 165,972 KB
実行使用メモリ 27,528 KB
最終ジャッジ日時 2023-08-27 15:23:08
合計ジャッジ時間 10,788 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
25,768 KB
testcase_01 AC 8 ms
25,832 KB
testcase_02 AC 8 ms
25,648 KB
testcase_03 AC 8 ms
25,720 KB
testcase_04 AC 8 ms
25,704 KB
testcase_05 AC 8 ms
25,708 KB
testcase_06 AC 9 ms
25,668 KB
testcase_07 AC 8 ms
25,720 KB
testcase_08 AC 8 ms
25,644 KB
testcase_09 AC 8 ms
25,808 KB
testcase_10 AC 9 ms
25,656 KB
testcase_11 AC 9 ms
25,676 KB
testcase_12 AC 8 ms
25,716 KB
testcase_13 AC 9 ms
25,956 KB
testcase_14 AC 9 ms
25,692 KB
testcase_15 AC 8 ms
25,952 KB
testcase_16 AC 8 ms
25,640 KB
testcase_17 AC 9 ms
25,952 KB
testcase_18 AC 9 ms
25,716 KB
testcase_19 AC 8 ms
25,644 KB
testcase_20 AC 8 ms
25,636 KB
testcase_21 AC 8 ms
25,648 KB
testcase_22 AC 9 ms
25,740 KB
testcase_23 AC 9 ms
26,004 KB
testcase_24 AC 9 ms
25,676 KB
testcase_25 AC 9 ms
25,712 KB
testcase_26 AC 8 ms
25,680 KB
testcase_27 AC 8 ms
25,744 KB
testcase_28 AC 9 ms
25,728 KB
testcase_29 AC 8 ms
25,652 KB
testcase_30 AC 8 ms
25,952 KB
testcase_31 AC 18 ms
25,936 KB
testcase_32 AC 21 ms
26,672 KB
testcase_33 AC 62 ms
26,744 KB
testcase_34 AC 122 ms
26,372 KB
testcase_35 AC 211 ms
27,068 KB
testcase_36 AC 126 ms
25,776 KB
testcase_37 AC 125 ms
26,068 KB
testcase_38 AC 115 ms
26,032 KB
testcase_39 AC 40 ms
26,352 KB
testcase_40 AC 41 ms
26,848 KB
testcase_41 AC 22 ms
26,744 KB
testcase_42 AC 165 ms
26,452 KB
testcase_43 AC 108 ms
25,728 KB
testcase_44 AC 160 ms
26,784 KB
testcase_45 AC 185 ms
26,400 KB
testcase_46 AC 16 ms
26,188 KB
testcase_47 AC 119 ms
26,544 KB
testcase_48 AC 29 ms
25,940 KB
testcase_49 AC 57 ms
26,464 KB
testcase_50 AC 193 ms
26,384 KB
testcase_51 AC 256 ms
27,212 KB
testcase_52 AC 247 ms
27,228 KB
testcase_53 AC 252 ms
27,208 KB
testcase_54 AC 245 ms
27,208 KB
testcase_55 AC 247 ms
27,528 KB
testcase_56 AC 28 ms
27,236 KB
testcase_57 AC 26 ms
27,268 KB
testcase_58 AC 162 ms
27,224 KB
testcase_59 AC 181 ms
27,392 KB
testcase_60 AC 79 ms
27,220 KB
testcase_61 AC 157 ms
27,272 KB
testcase_62 AC 151 ms
27,368 KB
testcase_63 AC 28 ms
27,272 KB
testcase_64 AC 82 ms
27,388 KB
testcase_65 AC 71 ms
27,216 KB
testcase_66 AC 67 ms
27,200 KB
testcase_67 AC 116 ms
27,516 KB
testcase_68 AC 82 ms
27,516 KB
testcase_69 AC 43 ms
27,212 KB
testcase_70 AC 50 ms
27,296 KB
testcase_71 AC 50 ms
27,396 KB
testcase_72 AC 101 ms
27,228 KB
testcase_73 AC 194 ms
27,432 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, char> P;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

struct node{
	int id,chl,chr,l,r;
	P v;
};

int n,m,s = 0;
node t[816225];
P ans[225816];

int init(int l=0, int r=n){
	int id;
	id = s; ++s;
	t[id].l = l; t[id].r = r;
	t[id].id = id; t[id].v = P(m,'@');
	if(r-l>1){
		t[id].chl = init(l,(l+r)/2);
		t[id].chr = init((l+r)/2,r);
	}
	return id;
}

void update(int a, int b, P v, int i=0, int l=0, int r=n){
	if(b<=l || r<=a){
		return;
	}else if(a<=l && r<=b){
		t[i].v = min(t[i].v,v);
	}else{
		update(a,b,v,t[i].chl,l,(l+r)/2);
		update(a,b,v,t[i].chr,(l+r)/2,r);
	}
}

int main(void){
	int i,l,r,y=0,k=0,c=0,j;
	char ch;
	cin >> n >> m;
	init();
	for(i=0; i<m; ++i){
		cin >> l >> r >> ch;
		update(l-1,r,P(i,ch));
	}
	for(i=0; i<n; ++i){
		l = 0; r = n;
		j = 0; ans[i] = t[j].v;
		while(r-l>1){
			m = (r+l)/2;
			if(i<m){
				j = t[j].chl;
				r = m;
			}else{
				j = t[j].chr;
				l = m;
			}
			ans[i] = min(ans[i],t[j].v);
		}
	}
	for(i=0; i<n; ++i){
		switch(ans[i].second){
			case 'Y':
			++y; break;
			case 'K':
			++k; break;
			case 'C':
			++c; break;
		}
	}
	cout << y << " " << k << " " << c << endl;
	return 0;
}
0