ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • Codeforces Round #497 (Div. 2)
    코드포스(CodeForce) 2018. 7. 15. 13:48
    반응형



    1. 문제 - http://codeforces.com/contest/1008/problem/A

    v 는 지금 막 baralnese 언어를 공부하기 시작했다. baralnese 는 라틴 알파뱃을 사용하는 것으로 알려져 있다.

    모음으로는 a,o,u,i,e 가 있다. 다른 글자들은 자음이다. 이 글자는 모음 뒤에는 모든 자음이 올 수 있다. 하지만 모음 뒤 에는 모음이 올 수 없다.

    단 하나의 예외는 'n' 이다. 

    이 글자 뒤에는 아무 문자나 올 수 있다(모음, 자음 상관이 없음) 또한 글자가 업슬 수 도 있다.


    2. 알고리즘

    키워드 - 구현, 문자열


    3. 코드


    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    #include <iostream>
    #include <sstream>
    #include <string>
    #include <algorithm>
    #include <functional>
    #include <vector>
    #include <list>
    #include <queue>
    #include <deque>
    #include <map>
    #include <set>
    #include <stack>
    #include <cstring>
     
    using namespace std;
     
    #define MAX_SIZE 100
    #define INF 0x7fffffff
    #define CENDL "\n"
    #define ll long long
     
    int main() {
     
        //cin.tie(0);
        //std::ios::sync_with_stdio(false);
        map<char , int> M;
        string s1;
        int flag = 0;
        M['a'= 1;M['e'= 1;M['i'= 1;M['o'= 1;M['u'= 1;
        cin >> s1;
     
        for(int i = ; i < s1.length() ; i++) {
            if(s1[i] == 'n') {
                continue;
            }
            else {
                if(M[s1[i]] != && M[s1[i+1]] != 1) {
                    flag = 1;
                    break;
                }
            }
        }
     
        if(flag== 1)     {
            printf("NO\n");
        }
        else {
            printf("YES\n");
        }
        return 0;
    }
    cs




    1. 문제 - http://codeforces.com/contest/1008/problem/B

    입력 받는 직사각형의 width, height 를 변경 하여 height 가 큰 순으로 정렬 하는 문제.

    단 주어진 조건에서 직사각형의 순서는 불가능 하다.


    2. 알고리즘

    키워드 - 정렬, 그리디


    3. 코드


    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    #include <iostream>
    #include <sstream>
    #include <string>
    #include <algorithm>
    #include <functional>
    #include <vector>
    #include <list>
    #include <queue>
    #include <deque>
    #include <map>
    #include <set>
    #include <stack>
    #include <cstring>
     
    using namespace std;
     
    #define MAX_SIZE 100
    #define INF 0x7fffffff
    #define CENDL "\n"
    #define ll long long
     
    /*
    * @memory  - 2056 kb
    * @time    - 0 ms
    */
     
    struct rect{
        int l;
        int r;
    }s[100005];
     
     
    int main() {
     
        cin.tie(0);
        std::ios::sync_with_stdio(false);
        int n; cin >> n;
     
        for (int i=0; i<n; i++) {
            cin >> s[i].l >> s[i].r;
        }
     
        int sol = 0;
     
        int PP = max(s[0].l,s[0].r);
        for(int i=0; i<n; i++) {        
            int MIN = min(s[i].l,s[i].r);
            int MAX = max(s[i].l,s[i].r);
            if(PP >= MAX)
            {
                PP = MAX;
            }
            else if(PP >= MIN)
            {
                PP = MIN;
            }
            else if(PP < MIN)
            {
                sol = 1;
                break;

            }
     
        }
     
        if (!sol) {
            cout << "YES";
        } else {
            cout << "NO";
        }
        
        return 0;
    }
     
    cs

    반응형

    댓글

Designed by Tistory.