4589호: 그놈 시퀀싱
All Creatures of Mythology라는 책에서 노움은 친절하고 수염이 난 생물인 반면 고블린은 독단적이고 단순한 생각을 하는 경향이 있습니다. 고블린은 턱수염 길이에 따라 노움을 3명씩 그룹으로 늘어서 괴롭히는 것을 좋아합니다. 격언
www.acmicpc.net
문제를 해결하다
각 테스트 케이스에 대해 3개의 숫자가 입력되고 3개의 숫자가 오름차순 또는 내림차순으로 정렬되는지 여부가 결정됩니다.
올바른 응답 코드
C++
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0)
#define ll long long
int main() {
fast;
int t;
cin >> t;
cout << "Gnomes:\n";
while(t--){
vector <int> lst(3);
for(int i = 0; i < 3; i++) cin >> lst(i);
if ((lst(1) - lst(0)) * (lst(2) - lst(1)) > 0) cout << "Ordered\n";
else cout << "Unordered\n";
}
}
파이썬
print("Gnomes:")
for _ in range(int(input())) :
lst = list(map(int, input().split()))
result = True
if (lst(2) - lst(1) >= 0 and lst(1) - lst(0) >= 0) or (lst(2) - lst(1) < 0 and lst(1) - lst(0) < 0) : print("Ordered")
else : print("Unordered")
