QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#358322#407. ToiletsGoodKnight0 0ms3628kbC++20829b2024-03-19 19:05:242024-03-19 19:05:35

Judging History

你现在查看的是最新测评结果

  • [2024-03-19 19:05:35]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:3628kb
  • [2024-03-19 19:05:24]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
long long n, k;
long long mal=0;
long long femal=0;
string s;
void solve1(){
    cin >> s;
    cin >> k;
    long long maxdif=0;
    bool endsinf=0;
    for(int i=0; i<2*n; i++){
        if(s[i]=='M') mal++;
        if(s[i]=='F') femal++;
        if(femal-mal>maxdif&&i%2==1){
            maxdif = femal-mal;
            if(s[i]=='F') endsinf=1;
            else endsinf=0;
        }
        if(femal-mal==maxdif&&i%2==1){
            if(s[i]=='M') endsinf = 0;
        }
    }
    if(femal<mal){
        cout << "-1";
        return;
    }
    long long wynik = maxdif-femal+mal;
    if(wynik%2==0&&endsinf) wynik--;
    cout << wynik;
    return;
}
int main(){
    cin >> n;
    int m;
    cin >> m;
    if(m==1){
        solve1();
    }
}


详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 14
Accepted
time: 0ms
memory: 3548kb

input:

10
1
FMFFFFFFMFFFMMMMMFMM 1

output:

5

result:

ok single line: '5'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3628kb

input:

10
1
FFMFMMFFFFMMMFMMMMFF 1

output:

3

result:

ok single line: '3'

Test #3:

score: -14
Wrong Answer
time: 0ms
memory: 3584kb

input:

10
1
MFMMFFFMMFFMMMMFFFFF 1

output:

-1

result:

wrong answer 1st lines differ - expected: '0', found: '-1'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #1:

0%