-
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. 코드
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051#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 longint 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 = 0 ; i < s1.length() ; i++) {if(s1[i] == 'n') {continue;}else {if(M[s1[i]] != 1 && 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. 코드
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374#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 반응형'코드포스(CodeForce)' 카테고리의 다른 글
Codeforces Round #428 (Div. 2) - A. Arya and Bran (0) 2018.08.17 Codeforces Round #479 (Div. 3) - B - Two-gram (0) 2018.08.17 Educational Codeforces Round 47 (Rated for Div. 2) (0) 2018.07.15 Codeforces Round #496 (Div. 3) (0) 2018.07.10 Codeforces Round #479 (Div. 3) (0) 2018.06.30