免責事項:この記事はブロガーオリジナル記事です、続くBY-SAのCC 4.0を著作権契約、複製、元のソースのリンクと、この文を添付してください。
C.は、整数を最小化
https://codeforces.com/contest/1251/problem/C
この質問はあまりにも彼らの良い食べ物ああ遅くされていた
あなたの照合を変更し、変更を与える唯一異なる隣接することができる彼らはまた、パリティラインを確保する必要があり
そうにも彼らは不可能ですが、この問題のパリティの異なる側面が簡単に彼らは異なる外観をしたいどのくらいの時間のために水に変えることができる前に変更することができパリティにリンクされているサンプルはすぐに順番にパリティデータを見られますご覧ください奇数-偶数ゆっくりと発見する必要はありません長い時間のために書きます
#include <bits/stdc++.h>
using namespace std;
const int maxn = 106 + 10;
int cas, n;
string str;
queue<char> o, e;
int main() {
cin >> cas;
while(cas --) {
cin >> str;
for(int i = 0; i < str.size(); i ++) {
if((str[i] - '0') % 2 == 1)
o.push(str[i]);
else
e.push(str[i]);
}
while(!o.empty() || !e.empty()) {
if(o.empty()) {
cout << e.front();
e.pop();
} else if(e.empty()) {
cout << o.front();
o.pop();
} else {
if(e.front() > o.front()) {
cout << o.front();
o.pop();
} else {
cout << e.front();
e.pop();
}
}
}
cout << endl;
//cout << str << endl;
}
return 0;
}