A. Digits Sequence Dividing
https://codeforces.com/problemset/problem/1107/A
주어진 string을 2개 이상으로 분리하는데, k번째 항은 k-1번째 항보다 커야한다.
간단하게 2개로 분리한다고 하면, string[0]과 나머지를 대소비교 하면 된다.
3자리 이상일 때는 무조건 string[0]이 작으므로, string의 길이가 2일때만 주의하면 된다.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #include <bits/stdc++.h> using namespace std; int t, n; string s; int main() { ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); cin >> t; while (t--) { cin >> n >> s; if (s.length() == 2 && (s[0] >= s[1])) { cout << "NO\n"; continue; } cout << "YES\n2\n"; cout << s[0] << " "; for (int i = 1; i < s.length(); i++) cout << s[i]; cout << '\n'; } return 0; } | cs |
'Competition > codeforces' 카테고리의 다른 글
Codeforces Round #536 (Div. 2) A. Lunar New Year and Cross Counting (0) | 2019.03.28 |
---|---|
Codeforces Round #536 (Div. 2) C. Lunar New Year and Number Division (0) | 2019.03.27 |
Codeforces Round #535 (Div. 3) A. Two distinct points (0) | 2019.03.27 |
Codeforces Global Round 1 A. Parity (0) | 2019.03.27 |
CodeCraft-19 and Codeforces Round #537 (Div. 2) A. Superhero Transformation (0) | 2019.03.27 |