結果
| 問題 | No.1469 programing |
| コンテスト | |
| ユーザー |
ManjushriMitra
|
| 提出日時 | 2025-01-03 17:15:12 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 67 ms / 3,000 ms |
| コード長 | 1,155 bytes |
| 記録 | |
| コンパイル時間 | 3,577 ms |
| コンパイル使用メモリ | 278,232 KB |
| 実行使用メモリ | 51,636 KB |
| 最終ジャッジ日時 | 2025-01-03 17:15:18 |
| 合計ジャッジ時間 | 6,004 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 15 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,m,n) for(int i=m; i<int(n); ++i)
#define repll(i,m,n) for(ll i=m; i<ll(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define fi first
#define se second
template<typename T> bool chmin(T& a, T b){ if(a > b){a = b; return true;} return false; }
template<typename T> bool chmax(T& a, T b){ if(a < b){a = b; return true;} return false; }
template<typename T> T gcd(T a, T b){ return a % b ? gcd(b, a % b) : b; }
template<typename T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
vector<pair<char, int>> run_length(string s){
int n = s.size();
vector<pair<char, int>> res;
char pre = s[0];
int cnt = 1;
rep(i, 1, n){
if(s[i] == pre){
++cnt;
}else{
res.push_back({pre, cnt});
pre = s[i], cnt = 1;
}
}
res.push_back({pre, cnt});
return res;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
string s;
cin >> s;
auto rle = run_length(s);
for(auto [c, l] : rle) cout << c;
cout << endl;
return 0;
}
ManjushriMitra