답안 #417688

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
417688 2021-06-04T06:40:48 Z 장태환(#7548) Parking Problem (innopolis2021_final_A) C++17
100 / 100
112 ms 1548 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>oo;
        priority_queue<int>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>o;
            priority_queue<int>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())
                {
                    int c=e.top()-2;
                    e.pop();
                      if(c>0)
                        e.push(c);
                }
                else if(o.size())
                {
                 int c=o.top()-2;

                    o.pop();
                     if(c>0)
                        o.push(c);
                }
            }
            else
            {
                if(o.size()&&((!e.size())||o.top()>1))
                {
                     int c=o.top()-3;

                    o.pop();
                     if(c>0)
                        e.push(c);
                }
                else if(e.size())
                {
                   int c=e.top()-3;
                    e.pop();
                      if(c>0)
                        o.push(c);
                }
            }

        }
            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:17:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |         for(i=0;i<a.size();i++)
      |                 ~^~~~~~~~~
Main.cpp:103:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  103 |         for(i=s;i<=b.size();i++)
      |                 ~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 708 KB Output is correct
2 Correct 22 ms 520 KB Output is correct
3 Correct 36 ms 636 KB Output is correct
4 Correct 33 ms 832 KB Output is correct
5 Correct 19 ms 576 KB Output is correct
6 Correct 33 ms 920 KB Output is correct
7 Correct 26 ms 460 KB Output is correct
8 Correct 41 ms 652 KB Output is correct
9 Correct 29 ms 692 KB Output is correct
10 Correct 24 ms 496 KB Output is correct
11 Correct 42 ms 628 KB Output is correct
12 Correct 27 ms 792 KB Output is correct
13 Correct 21 ms 548 KB Output is correct
14 Correct 50 ms 592 KB Output is correct
15 Correct 32 ms 508 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 33 ms 828 KB Output is correct
2 Correct 23 ms 492 KB Output is correct
3 Correct 43 ms 564 KB Output is correct
4 Correct 35 ms 752 KB Output is correct
5 Correct 23 ms 496 KB Output is correct
6 Correct 27 ms 716 KB Output is correct
7 Correct 24 ms 556 KB Output is correct
8 Correct 46 ms 552 KB Output is correct
9 Correct 38 ms 1460 KB Output is correct
10 Correct 27 ms 1312 KB Output is correct
11 Correct 49 ms 1508 KB Output is correct
12 Correct 33 ms 1384 KB Output is correct
13 Correct 25 ms 1228 KB Output is correct
14 Correct 46 ms 1476 KB Output is correct
15 Correct 40 ms 1092 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 95 ms 736 KB Output is correct
2 Correct 63 ms 580 KB Output is correct
3 Correct 45 ms 536 KB Output is correct
4 Correct 32 ms 564 KB Output is correct
5 Correct 31 ms 460 KB Output is correct
6 Correct 36 ms 580 KB Output is correct
7 Correct 43 ms 540 KB Output is correct
8 Correct 45 ms 580 KB Output is correct
9 Correct 31 ms 548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 708 KB Output is correct
2 Correct 22 ms 520 KB Output is correct
3 Correct 36 ms 636 KB Output is correct
4 Correct 33 ms 832 KB Output is correct
5 Correct 19 ms 576 KB Output is correct
6 Correct 33 ms 920 KB Output is correct
7 Correct 26 ms 460 KB Output is correct
8 Correct 41 ms 652 KB Output is correct
9 Correct 29 ms 692 KB Output is correct
10 Correct 24 ms 496 KB Output is correct
11 Correct 42 ms 628 KB Output is correct
12 Correct 27 ms 792 KB Output is correct
13 Correct 21 ms 548 KB Output is correct
14 Correct 50 ms 592 KB Output is correct
15 Correct 32 ms 508 KB Output is correct
16 Correct 33 ms 828 KB Output is correct
17 Correct 23 ms 492 KB Output is correct
18 Correct 43 ms 564 KB Output is correct
19 Correct 35 ms 752 KB Output is correct
20 Correct 23 ms 496 KB Output is correct
21 Correct 27 ms 716 KB Output is correct
22 Correct 24 ms 556 KB Output is correct
23 Correct 46 ms 552 KB Output is correct
24 Correct 38 ms 1460 KB Output is correct
25 Correct 27 ms 1312 KB Output is correct
26 Correct 49 ms 1508 KB Output is correct
27 Correct 33 ms 1384 KB Output is correct
28 Correct 25 ms 1228 KB Output is correct
29 Correct 46 ms 1476 KB Output is correct
30 Correct 40 ms 1092 KB Output is correct
31 Correct 95 ms 736 KB Output is correct
32 Correct 63 ms 580 KB Output is correct
33 Correct 45 ms 536 KB Output is correct
34 Correct 32 ms 564 KB Output is correct
35 Correct 31 ms 460 KB Output is correct
36 Correct 36 ms 580 KB Output is correct
37 Correct 43 ms 540 KB Output is correct
38 Correct 45 ms 580 KB Output is correct
39 Correct 31 ms 548 KB Output is correct
40 Correct 1 ms 204 KB Output is correct
41 Correct 1 ms 204 KB Output is correct
42 Correct 2 ms 204 KB Output is correct
43 Correct 6 ms 500 KB Output is correct
44 Correct 4 ms 332 KB Output is correct
45 Correct 5 ms 408 KB Output is correct
46 Correct 30 ms 1052 KB Output is correct
47 Correct 91 ms 1548 KB Output is correct
48 Correct 69 ms 1532 KB Output is correct
49 Correct 112 ms 1432 KB Output is correct