結果

問題 No.449 ゆきこーだーの雨と雪 (4)
ユーザー guestguest
提出日時 2016-11-20 10:25:51
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,531 bytes
コンパイル時間 1,922 ms
コンパイル使用メモリ 184,676 KB
実行使用メモリ 11,784 KB
最終ジャッジ日時 2023-10-23 15:58:02
合計ジャッジ時間 12,432 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,972 KB
testcase_01 AC 4 ms
6,972 KB
testcase_02 AC 4 ms
6,972 KB
testcase_03 AC 5 ms
6,972 KB
testcase_04 AC 5 ms
6,972 KB
testcase_05 AC 5 ms
6,972 KB
testcase_06 AC 4 ms
6,972 KB
testcase_07 AC 4 ms
6,972 KB
testcase_08 AC 4 ms
6,972 KB
testcase_09 AC 5 ms
6,972 KB
testcase_10 AC 7 ms
6,972 KB
testcase_11 AC 5 ms
6,972 KB
testcase_12 AC 159 ms
7,764 KB
testcase_13 AC 3,013 ms
11,784 KB
testcase_14 TLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>


#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define dnmin(a,b) (a)=min((a),(b))

using namespace std;
typedef vector<int> VI;
typedef pair<int, int> pii;

struct Bitree {
	typedef int btT;
	vector<btT> bv;
	Bitree(int n) : bv(n + 3) {}
	btT sum(int i) {
		btT res=0; for(i++; i>0; i -= i & -i) res += bv[i]; return res;
	}
	btT sum(int a, int b) {return sum(b) - (a? sum(a-1): 0);}
	void add(int i, btT x){for(i++; i<(int)bv.size(); i += i & -i) bv[i] += x; }
};


int main(){
 
	int n, t, mno=0;
	cin >>n;
	VI hs(n);
	unordered_map<string, VI> mp;
	Bitree bta(600*27);
	vector<VI> va(600*27);
	rep(i,n) cin >>hs[i];
	cin >> t;
	VI nos(n);
	vector<string> rcv(100010);
	rep(i, t){
		string s; char a;
		cin >> s >> a;
		if(!mp.count(s)){
			mp[s] = VI{ 0,0, ++mno};
			rcv[mp[s][2]] = s;
		}
		if(a != '?'){
			if(mp[s][0] !=0){
				bta.add(mp[s][0], -1);
			}
			mp[s][1] = i+1;
			int mz= a-'A';
			mp[s][0] += 50 * hs[mz] + (500 * hs[mz]) / (8 + 2* (++nos[mz]));
			bta.add(mp[s][0], 1);
			va[mp[s][0]].push_back(mp[s][2]);
		}else{
			int ans = bta.sum( mp[s][0] + 1, 600*27);
			auto& wv = va[mp[s][0]];
			int delct=0;
			rep(j,sz(wv)){
				if(wv[j] ==-1){ delct++; continue;}
				if(mp[rcv[wv[j]]][0] != mp[s][0]){
					delct++; wv[j] = -1;
					continue;
				}
				if(wv[j] == mp[s][2]) break;
				else ans++;
			}
			if(delct > 99) wv.erase(remove(all(wv),-1), wv.end());
			cout << ans + 1 <<"\n";
		}
	}
	
	return 0;
}
 
0