题目描述
blablabla
样例
blablabla
算法1
(暴力枚举) $O(n^2)$
blablabla
时间复杂度
参考文献
C++ 代码
blablabla
算法2
(暴力枚举) $O(n^2)$
blablabla
时间复杂度
参考文献
JavaScript 代码
var readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
var str =[]
rl.on('line', (line)=>{
var tokens = line.split('');
str = str.concat(tokens)
if(line.includes('E'))
{
var win = 0
var lost = 0
var end = 0
str.forEach(item => {
if(end === 0){
if (item === 'W') {
win++
} else if (item === 'L') {
lost++
} else {
console.log(win + ':' + lost)
//胜负清零
win = 0
lost = 0
end =1
}
if(win-lost>=2||lost-win>=2){
if (win >= 11 || lost >= 11) {
console.log(win + ':' + lost)
//胜负清零
win = 0
lost = 0
}
}
}
})
console.log()
win = 0
lost = 0
end = 0
str.forEach(item => {
if(end === 0){
if (item === 'W') {
win++
} else if (item === 'L') {
lost++
} else {
console.log(win + ':' + lost)
//胜负清零
win = 0
lost = 0
end = 1
}
if(win-lost>=2||lost-win>=2){
if (win >= 21 || lost >= 21) {
console.log(win + ':' + lost)
//胜负清零
win = 0
lost = 0
}
}
}
})
}
});