QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#358320#407. Toiletsmkolko0 1ms3628kbC++171.8kb2024-03-19 19:05:242024-03-19 19:05:26

Judging History

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

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

answer

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int dane[100'007];
vector<int> tab;

int fun(int n)
{
    int kob=tab.size()-1, koe=tab.size()-1;
    for(int a=0; a<n; a++)
    {
        while(tab[kob]==-1 || tab[kob]==0)
            kob--;
        if(tab[kob]==-69)
            return 0;
        tab[kob]=-1;
        //cout<<kob<<" ";

        while(tab[koe]==-1)
            koe--;
        if(tab[koe]==-69)
            return 0;
        tab[koe]=-1;
        //cout<<koe<<"\n";
    }
    return 1;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
    string s;
    int n, m, p, odp=0, suma=0;
    cin>>n>>m>>s>>p;
    reverse(s.begin() , s.end());
    for(int a=0; a<n*2; a++)
    {
        if(s[a]=='F'){
            suma++;
            dane[a]=1;
        }
    }
    for(int a=18; a>=0; a--)
    {
        tab.clear();
        tab.push_back(-69);
        for(int i=0; i<n*2; i++)
        {
            //cout<<tab.size()<<" "<<i<<" "<<dane[i]<<"    ";
            if(dane[i]==1 || tab.size()-1-i +odp+(1<<a)<= 0)
                tab.push_back(dane[i]);
        }
        for(int i=tab.size()-1; i<n*2; i++)
            tab.push_back(0);
        /*for(int i=0; i<tab.size(); i++)
            cout<<tab[i]<<" ";
        cout<<endl;
        cout<<fun(n,tab)<<" "<<odp<<" "<<(1<<a)<<"|\n";*/
        if(fun(n)==0)
            odp=odp+(1<<a);
    }
    tab.clear();
    tab.push_back(-69);
    for(int i=0; i<n*2; i++)
    {
        if(dane[i]==1 || tab.size()-1-i +odp<= 0)
            tab.push_back(dane[i]);
    }
    for(int i=tab.size()-1; i<n*2; i++)
        tab.push_back(0);
    if(fun(n)==0)
        odp++;
    if(odp==2097152)
        cout<<-1;
    else
        cout<<odp;
    return 0;
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 14
Accepted
time: 1ms
memory: 3628kb

input:

10
1
FMFFFFFFMFFFMMMMMFMM 1

output:

5

result:

ok single line: '5'

Test #2:

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

input:

10
1
FFMFMMFFFFMMMFMMMMFF 1

output:

3

result:

ok single line: '3'

Test #3:

score: 0
Accepted
time: 1ms
memory: 3544kb

input:

10
1
MFMMFFFMMFFMMMMFFFFF 1

output:

0

result:

ok single line: '0'

Test #4:

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

input:

10
1
FMFMFFMFMFMMFFMFMFMM 1

output:

1

result:

ok single line: '1'

Test #5:

score: -14
Wrong Answer
time: 1ms
memory: 3492kb

input:

10
1
MFFFMFMMMMMMMMMFMFFM 1

output:

524288

result:

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

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #1:

0%