AT_scpc2026_div2_g.SCSC Game

入门

通过率:0%

时间限制:2.00s

内存限制:1024MB

AC君温馨提醒

该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

This year, FuriosaAI officially announced mass production of RNGD, its second-generation AI accelerator. RNGD is specialized for processing language models and multimodal models, and provides powerful computing performance even with low power consumption.

At SCSC, AI agents Lulu and Terra were created using RNGD chips, and SCSC had them play the SCSC game for performance testing.

The SCSC game is played with a string SS consisting of uppercase letters S and C that does not contain SCSC as a substring. Lulu and Terra take turns, with Terra going first. On each turn, the current player chooses one character from the string and removes it. If, after the removal, the string contains SCSC as a substring, that player wins and the other player loses. If the current player can no longer choose any character to remove, that player loses and the other player wins.

Thanks to the powerful computing performance of the RNGD chips, Lulu and Terra have become able to always find optimal moves to win. Given the string SS, determine which agent wins the game if both Lulu and Terra play optimally.

What is a substring? A substring of a string is a contiguous part of the original string. For example, `bc` is a substring of `abcd`, but `ac` is not. Multiple substrings may overlap within the same string. For example, `aba` appears a total of 22 times in `ababa`.

今年,FuriosaAI 正式宣布其第二代 AI 加速器 RNGD 进入量产阶段。RNGD 专为处理语言模型与多模态模型而设计,即使在低功耗下也能提供强大的计算性能。

在 SCSC,AI 智能体 Lulu 和 Terra 均基于 RNGD 芯片构建;SCSC 让它们对弈 SCSC 游戏以进行性能测试。

SCSC 游戏使用一个仅由大写字母 S 和 C 构成的字符串 SS 进行,且该字符串不包含子串 SCSC。Lulu 和 Terra 轮流操作,Terra 先手。每回合,当前玩家从字符串中选择一个字符并将其移除。若移除后字符串中出现子串 SCSC,则当前玩家获胜,另一方失败。若当前玩家已无法选择任何字符移除,则当前玩家失败,另一方获胜。

得益于 RNGD 芯片的强大算力,Lulu 和 Terra 总能找到最优策略以确保胜利。给定字符串 SS,请判断:当双方均采用最优策略时,哪位智能体将赢得游戏。

什么是子串?一个字符串的子串是指该字符串中一段连续的字符序列。例如,`bc` 是 `abcd` 的子串,但 `ac` 不是。同一字符串中可能存在多个重叠的子串。例如,`aba` 在 `ababa` 中共出现 22 次。

输入格式

The input is given from Standard Input in the following format:

TT
case1\mathrm{case}_1
case2\mathrm{case}_2
⋮\vdots
caseT\mathrm{case}_T

Each test case is given in the following format:

SS

输入从标准输入给出,格式如下:

TT
case1\mathrm{case}_1
case2\mathrm{case}_2
⋮\vdots
caseT\mathrm{case}_T

每个测试用例的格式如下:

SS

输出格式

For each test case, output Terra if Terra wins, and Lulu if Lulu wins, one per line.

对于每个测试用例,若 Terra 获胜则输出 Terra,若 Lulu 获胜则输出 Lulu,每行一个。

输入输出样例

  • 输入#1

    2
    SCSSCCS
    SSSS

    输出#1

    Terra
    Lulu

说明/提示

表示言語

/ /

Constraints

  • 1≤T≤10 0001 \leq T \leq 10\,000
  • 1≤∣S∣≤200 0001 \leq |S| \leq 200\,000
  • SS consists only of uppercase letters S and C, and does not contain SCSC as a substring.
  • The sum of ∣S∣|S| over all test cases does not exceed 200 000200\,000.

表示语言

/ /

约束条件

  • 1≤T≤10 0001 \leq T \leq 10\,000
  • 1≤∣S∣≤200 0001 \leq |S| \leq 200\,000
  • 字符串 SS 仅由大写字母 S 和 C 组成,且不包含子串 SCSC。
  • 所有测试用例的 ∣S∣|S| 之和不超过 200 000200\,000。

输入解题思路,AI测评打分。不知道怎么写?

首页