Competition/codeforces
Educational Codeforces Round 53 (Rated for Div. 2) A. Diverse Substring
shyram
2019. 3. 30. 03:58
A. Diverse Substring
https://codeforces.com/problemset/problem/1073/A
여러번 볼 필요 없이 2개씩만 비교해서 다른 문자들이 나온다면 출력해주자.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #include <bits/stdc++.h> using namespace std; int n; string s; int main() { ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); cin >> n >> s; for (int i = 0; i < n-1; i++) { if (s[i] != s[i + 1]) { cout << "YES\n" << s[i] << s[i + 1]; exit(0); } } cout << "NO"; return 0; } | cs |