LeetCode Weekly Contest 183
問題文
省略
省略
C++に変換後のコードはこちら
#define main dummy_main
{}
#undef main
class Solution {
public:
string longestDiverseString(int a, int b, int c) {
string res;
char aa = 'a', bb = 'b', cc = 'c';
if(a < b) swap(a, b), swap(aa, bb);
if(b < c) swap(b, c), swap(bb, cc);
if(a < b) swap(a, b), swap(aa, bb);
for(;;){
if(b==c==0){
rep(min(a,2)) res += aa, a--;
break;
}
if(a > b){
res += aa, a--;
if(a > b) res += aa, a--;
if(b == c) res += cc, c--;
else res += bb, b--;
continue;
}
res += aa, a--;
res += bb, b--;
if(c) res += cc, c--;
}
return res;
}
};
Current time: 2024年04月27日04時40分52秒
Last modified: 2020年04月10日06時28分41秒 (by laycrs)
Tags: Competitive_Programming_Incomplete LeetCode
トップページに戻る
Logged in as: unknown user (not login)