Google APAC 2017 Round A - 不正确

时间:2016-07-13 16:06:22

标签: c++ algorithm

我想知道是否有人可以提供一些帮助来审核下面的代码?我尝试过Google APAC 2017 Round A但是被第一个问题所困扰,其链接是https://code.google.com/codejam/contest/11274486/dashboard

事实上,我有一些输出,他们似乎都是正确的,而在线评判并没有这么说。如果有人愿意扫描代码并进行一些讨论,我们将非常感激。谢谢!

string A()
{
    int N;
    cin >> N;
    cin.get();
    string leader, cur;
    int i = 0, j = 0, L = 0, leaderLetterNum = 0;
    set<char> letters;
    for(i = 0; i < N; i++)
    {
        getline(cin, cur);
        L = cur.empty() ? 0 : cur.length();
        for(j = 0; j < L; ++j)
        {
            if(cur[j] >= 'A' && cur[j] <= 'Z') letters.insert(cur[j]);
        }
        if(leader.empty() || letters.size() > leaderLetterNum)
        {
            leader.clear();
            leader = cur;
            leaderLetterNum = letters.size();
        }
        cur.clear();
        letters.clear();
    }
    return leader;
}

void multiTest()
{
    int T;
    cin >> T;
    int caseCount = 0;
    while(caseCount++ < T)
    {
        cout << "Case #" << caseCount << ": " << A() << endl;
    }
    return;
}

int main(void)
{
    multiTest();
    return 0;
}

1 个答案:

答案 0 :(得分:0)

你错过了这个条件

  

如果存在平局,那么名字最早按字母顺序排列的人就是领导者。

尝试使用

func tableView(tableView: UITableView, estimatedHeightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
    return XXXXX // Provide your estimation here, or pass UITableViewAutomaticDimension (not the best for performances)
}

而不是

if(leader.empty() || letters.size() > leaderLetterNum ||
(letters.size() == leaderLetterNum && cur < leader))
相关问题