結果

問題 No.434 占い
ユーザー Kmcode1Kmcode1
提出日時 2016-10-15 00:03:02
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,461 bytes
コンパイル時間 2,564 ms
コンパイル使用メモリ 150,296 KB
実行使用メモリ 6,468 KB
最終ジャッジ日時 2023-08-14 11:28:03
合計ジャッジ時間 5,088 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 1 ms
4,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 3 ms
4,380 KB
testcase_13 AC 22 ms
4,380 KB
testcase_14 WA -
testcase_15 AC 238 ms
6,468 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 17 ms
4,380 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 10 ms
4,380 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int t;

char buf[100002];

vector<pair<int, int> > v;

void reset(vector<pair<int, int> > &r){
	vector<pair<int, int> > f;
	int pr = r[0].first;
	int cnt = 0;
	for (int i = 0; i < r.size(); i++){
		if (pr == r[i].first){
			cnt += r[i].second;
		}
		else{
			f.push_back(make_pair(pr, cnt));
			pr = r[i].first;
			cnt = r[i].second;
		}
	}
	f.push_back(make_pair(pr, cnt));
	r = f;
}
int main(){
	cin >> t;
	while (t--){
		scanf("%s", buf);
		v.clear();
		int siz = strlen(buf);
		for (int i = 0; i < siz; i++){
			v.push_back(make_pair(buf[i] - '0', 1));
		}
		reset(v);
		while (v.size()>1 || (v.size() == 1 && v[0].second>1)){
			vector<pair<int, int> > tmp;
			int pr = -1;
			for (int i = 0; i < v.size(); i++){
				if (v[i].second > 1){
					int K = v[i].first + v[i].first;
					if (K >= 10){
						K %= 10;
						K++;
					}
					tmp.push_back(make_pair(K, v[i].second - 1));
				}
				if (i + 1 < v.size()){
					int F = v[i].first + v[i + 1].first;
					if (F >= 10){
						F %= 10;
						F++;
					}
					tmp.push_back(make_pair(F, 1));
				}
			}
			v = tmp;
			reset(v);
			tmp.clear();
			int maxxx = 11451411;
			for (int i = 0; i < v.size(); i++){
				if (v[i].first == 9){
					maxxx = min(maxxx, v[i].second);
				}
			}
			for (int i = 0; i < v.size(); i++){
				if (v[i].first == 9){
					v[i].second -= maxxx;
				}
				else{
					
				}
			}
		}
		printf("%d\n", v[0].first);
	}
	return 0;
}
0