結果

問題 No.1469 programing
ユーザー Example0911Example0911
提出日時 2021-04-09 21:20:43
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 66 ms / 3,000 ms
コード長 608 bytes
コンパイル時間 2,377 ms
コンパイル使用メモリ 202,068 KB
実行使用メモリ 51,284 KB
最終ジャッジ日時 2023-09-07 09:32:30
合計ジャッジ時間 3,490 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 4 ms
4,376 KB
testcase_09 AC 5 ms
4,384 KB
testcase_10 AC 4 ms
4,412 KB
testcase_11 AC 8 ms
5,484 KB
testcase_12 AC 6 ms
5,460 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 10 ms
8,368 KB
testcase_15 AC 7 ms
5,804 KB
testcase_16 AC 9 ms
6,328 KB
testcase_17 AC 66 ms
51,284 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
//#define int long long
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = (1LL << 61);
ll mod = 1000000007;
vector<pair<char, int>> RunLength(string s) {
	if (s.size() == 0)return {};
	vector<pair<char, int>>res(1, pair<char, int>(s[0], 0));
	for (char p : s) {
		if (res.back().first == p) {
			res.back().second++;
		}
		else {
			res.emplace_back(p, 1);
		}
	}
	return res;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string S; cin >> S;
	auto p = RunLength(S);
	for (auto x : p) {
		cout << x.first;
	}cout << endl;
	return 0;
}
0