답안 #417656

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
417656 2021-06-04T06:02:07 Z 장태환(#7548) Parking Problem (innopolis2021_final_A) C++17
54 / 100
35 ms 860 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>o,e;
        for(i=0;i<a.size();i++)
        {
            if(a[i]=='X')
            {
                if(c>1)
                {
                    if(c%2)
                        e.push(c-1);
                    else
                        o.push(c-1);
                }
                c=0;
            }
            else
                c++;
        }
        if(c>1)
        {
            if(c%2)
                e.push(c-1);
            else
                o.push(c-1);
        }
        for(i=0;i<b.size();i++)
        {
            cout <<((e.size()+o.size())?'Y':'N');
            if(b[i]=='M')
            {
                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();
                }
            }

        }
         cout <<((e.size()+o.size())?'Y':'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:39:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |         for(i=0;i<b.size();i++)
      |                 ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 744 KB Output is correct
2 Correct 18 ms 532 KB Output is correct
3 Correct 30 ms 648 KB Output is correct
4 Correct 15 ms 824 KB Output is correct
5 Correct 15 ms 460 KB Output is correct
6 Correct 16 ms 860 KB Output is correct
7 Correct 20 ms 488 KB Output is correct
8 Correct 31 ms 600 KB Output is correct
9 Correct 12 ms 752 KB Output is correct
10 Correct 16 ms 556 KB Output is correct
11 Correct 34 ms 580 KB Output is correct
12 Correct 13 ms 792 KB Output is correct
13 Correct 14 ms 520 KB Output is correct
14 Correct 35 ms 580 KB Output is correct
15 Correct 29 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 784 KB Output is correct
2 Correct 15 ms 556 KB Output is correct
3 Correct 33 ms 608 KB Output is correct
4 Correct 19 ms 724 KB Output is correct
5 Incorrect 18 ms 468 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 736 KB Output is correct
2 Correct 19 ms 624 KB Output is correct
3 Correct 19 ms 548 KB Output is correct
4 Correct 19 ms 560 KB Output is correct
5 Correct 21 ms 548 KB Output is correct
6 Correct 24 ms 496 KB Output is correct
7 Correct 29 ms 608 KB Output is correct
8 Correct 33 ms 640 KB Output is correct
9 Correct 25 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 744 KB Output is correct
2 Correct 18 ms 532 KB Output is correct
3 Correct 30 ms 648 KB Output is correct
4 Correct 15 ms 824 KB Output is correct
5 Correct 15 ms 460 KB Output is correct
6 Correct 16 ms 860 KB Output is correct
7 Correct 20 ms 488 KB Output is correct
8 Correct 31 ms 600 KB Output is correct
9 Correct 12 ms 752 KB Output is correct
10 Correct 16 ms 556 KB Output is correct
11 Correct 34 ms 580 KB Output is correct
12 Correct 13 ms 792 KB Output is correct
13 Correct 14 ms 520 KB Output is correct
14 Correct 35 ms 580 KB Output is correct
15 Correct 29 ms 460 KB Output is correct
16 Correct 17 ms 784 KB Output is correct
17 Correct 15 ms 556 KB Output is correct
18 Correct 33 ms 608 KB Output is correct
19 Correct 19 ms 724 KB Output is correct
20 Incorrect 18 ms 468 KB Output isn't correct
21 Halted 0 ms 0 KB -