Submission #417679

# Submission time Handle Problem Language Result Execution time Memory
417679 2021-06-04T06:29:07 Z 장태환(#7548) Parking Problem (innopolis2021_final_A) C++17
0 / 100
154 ms 840 KB
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int T;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> T;
    while(T--)
    {
        string a,b;
        cin >> a >> b ;
        int i;
        int c=0;
        priority_queue<int,vector<int>,greater<int>>oo,ee;
        for(i=0;i<a.size();i++)
        {
            if(a[i]=='X')
            {
                if(c>1)
                {
                    if(c%2)
                        ee.push(c-1);
                    else
                        oo.push(c-1);
                }
                c=0;
            }
            else
                c++;
        }
        if(c>1)
        {
            if(c%2)
                ee.push(c-1);
            else
                oo.push(c-1);
        }
        int s=0,en=b.size()+1;
        while(s!=en)
        {
            priority_queue<int,vector<int>,greater<int>>o,e;
            o=oo;
            e=ee;
            int m=(s+en)/2;
            int three=0,two=0;
            for(i=0;i<m;i++)
            {
                if(b[i]=='M')
                    two++;
                else
                    three++;
            }
            for(i=0;i<three+two;i++)
            {
                if(i>=three)
            {
                if(e.size())
                {
                    if(e.top()>2)
                        e.push(e.top()-2);
                    e.pop();
                }
                else if(o.size())
                {
                    if(o.top()>2)
                        o.push(o.top()-2);
                    o.pop();
                }
            }
            else
            {
                if(o.size())
                {
                    if(o.top()>3)
                        e.push(o.top()-3);
                    o.pop();
                }
                else if(e.size())
                {
                    if(e.top()>3)
                        o.push(e.top()-3);
                    e.pop();
                }
            }

        }
            if(e.size()||o.size())
                s=m+1;
            else
                en=m;
        }
        for(i=0;i<s;i++)
            cout <<'Y';
        for(i=s;i<=b.size();i++)
            cout <<'N';
        cout <<'\n';
    }
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:16:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |         for(i=0;i<a.size();i++)
      |                 ~^~~~~~~~~
Main.cpp:95:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   95 |         for(i=s;i<=b.size();i++)
      |                 ~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 55 ms 684 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 75 ms 840 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 154 ms 700 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 55 ms 684 KB Output isn't correct
2 Halted 0 ms 0 KB -