Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
72738 杨莹斌 行程长度压缩 C++ Accepted 1 MS 288 KB 400 2024-05-12 17:02:50

Tests(10/10):


Code:

#include<bits/stdc++.h> using namespace std; int main(){ string s; cin >> s; int n = s.size(); for(int i = 0;i <n;i++){ if(s[i] >= 'a' && s[i] <= 'z'){ s[i] -= 32; } } int sum = 0; for(int i = 0;i <n;i++){ if(i == 0 || s[i]==s[i-1]){ sum++; }else{ cout<<"("<<s[i-1]<<","<<sum<<")"; sum = 1; } } cout<<"("<<s[n-1]<<","<<sum<<")"; return 0; }