Educational Codeforces Round 75 (Rated for Div. 2) A (简单模拟)

mac2025-12-17  9

http://codeforces.com/contest/1251/problem/A

#include "cstdio" #include "cstring" #include "iostream" #include "algorithm" #include "string.h" #include "string" using namespace std; typedef double D; typedef long long ll; const int N = 100007; const int Mx = 1e9 + 7; bool can[N]; void solve() { for(int i = 'a' ; i <= 'z'; ++i) can[i] = false ; string s; cin >> s; for(int i = 0; i < (int)s.size(); ++i) { int wsk = i; while(wsk + 1 < (int)s.size() && s[wsk + 1] == s[i]) ++wsk; if((wsk - i + 1) & 1) can[s[i]] = true; i = wsk; } for(int i = 'a' ; i <= 'z' ; ++i) if(can[i]) cout << (char)i; cout <<"\n"; } int main() { int casee; cin >> casee ; while(casee--) solve(); return 0; }
最新回复(0)