第十二届东南大学短码竞赛 - 热身赛

欢迎参加第十二届短码竞赛 - 热身赛!

2025-03-24 12:00:00
2025-03-30 12:00:00
排行榜 提交记录 问答

信息与公告

这是第十二届东南大学短码竞赛 - 热身赛。

正式比赛中,仅可在 cpp11/cpp17/c/java/python2/python3/nodejs/kotlin 中选择使用单个语言参赛;比赛沿用东南短码21计分规则:每题选手得分为 100 的该题最短代码长度/选手提交长度之商的平方根次方,总分为各题之和。

C/C++ 和 Java 的代码长度按每行去掉行首行末空白符、非预处理指令首行的回车符计算;其他语言按代码真实长度计算;Python 的代码长度在作为比赛成绩的计算参数时额外乘 2。

附件:短码得分统计规则(东南短码 21)

// The following script is executed by Node.js v14.19.3.

/**
 * Calculate the length of the submitted code being counted.
 * @param {string} code The content of submitted code.
 * @param {string} lang The abbr. of the language used by the code.
 * @returns {number} the length of the submitted code being counted
 */
function calcCodeLength(code, lang) { // Only support Java/C/Python/Kotlin/Nodejs
  lang = lang.toLowerCase();
  let isC = lang.startsWith('c');
  let isJava = lang.startsWith('j');
  code = code.replace(/\r\n/g,'\n');
  if (isC) {
    return code.split('\n').map(x => {
      let y = x.trim();
      if (y.startsWith('#')) y += '\n';
      return y;
    }).join('').length; 
  } else if (isJava) return code.split('\n').map(x => x.trim()).join('').length;
  else if (lang.startsWith('py')) return code.length * 2; // 2021 Python special rule
  else return code.length; // Like Kotlin/Nodejs
}

/**
 * Calculate the player's score for one problem.
 * @param {number} len The shortest code length of this problem for this player.
 * @param {number} minLen The shortest code length of this problem among all players.
 * @returns {number} The score of this problem for this player, can be float.
 */
function calcCodeScore(len, minLen) { 
  return Math.pow(100, Math.sqrt(minLen / len));
}