Advertisement
dimuster

cf po prikolu

May 7th, 2022
773
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.64 KB | None | 0 0
  1. https://codeforces.com/problemset/problem/1144/A
  2.  
  3. #include <bits/stdc++.h>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8.    
  9.     int t;
  10.     cin >> t;
  11.     while (t--) {
  12.         string s;
  13.         vector<int> a(26, 0);
  14.         cin >> s;
  15.         for (int i = 0; i < s.size(); i++) {
  16.             a[s[i] - 'a']++;
  17.         }
  18.         int sum = 0, mxl = 0, l = 0;
  19.         bool isDouble = false;
  20.         for (int i = 0; i < 26; i++) {
  21.             if (a[i] > 1) {
  22.                 isDouble = true;
  23.             }
  24.             if (a[i] == 1) {
  25.                 sum++;
  26.                 l++;
  27.                 if (mxl < l) mxl = l;
  28.             } else {
  29.                 l = 0;
  30.             }
  31.         }
  32.         if (mxl == sum && !isDouble) {
  33.             cout << "Yes\n";
  34.         } else {
  35.             cout << "No\n";
  36.         }
  37.     }
  38.    
  39.     return 0;
  40. }
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52. https://codeforces.com/problemset/problem/129/A
  53.  
  54. #include <bits/stdc++.h>
  55.  
  56. using namespace std;
  57.  
  58. int main() {
  59.    
  60.     int n, sum = 0, chet = 0, nechet = 0;
  61.     cin >> n;
  62.     while (n--) {
  63.         int x;
  64.         cin >> x;
  65.         x % 2 == 0 ? chet++ : nechet++;
  66.         sum += x;
  67.     }
  68.     cout << (sum % 2 == 0 ? chet : nechet);
  69.    
  70.     return 0;
  71. }
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78. https://codeforces.com/problemset/problem/1450/A
  79.  
  80. #include <bits/stdc++.h>
  81.  
  82. using namespace std;
  83.  
  84. int main() {
  85.    
  86.     int t;
  87.     cin >> t;
  88.     while (t--) {
  89.         int n;
  90.         string s;
  91.         cin >> n >> s;
  92.         int t_count = 0;
  93.         for (int i = 0; i < n; i++) {
  94.             if (s[i] != 't') {
  95.                 cout << s[i];
  96.             } else {
  97.                 t_count++;
  98.             }
  99.         }
  100.         while (t_count--) cout << 't';
  101.         cout << "\n";
  102.     }
  103.    
  104.     return 0;
  105. }
  106.  
  107.  
  108.  
  109.  
  110. https://codeforces.com/problemset/problem/1602/A
  111.  
  112. #include <bits/stdc++.h>
  113.  
  114. using namespace std;
  115.  
  116. int main() {
  117.    
  118.     int t;
  119.     cin >> t;
  120.     while (t--) {
  121.         string s;
  122.         cin >> s;
  123.         char mn = 'z';
  124.         for (int i = 0; i < s.size(); i++) {
  125.             if (mn > s[i]) mn = s[i];
  126.         }
  127.         cout << mn << " ";
  128.         for (int i = 0; i < s.size(); i++) {
  129.             if (mn == s[i]) {
  130.                 mn = '-';
  131.                 continue;
  132.             }
  133.             cout << s[i];
  134.         }
  135.         cout << "\n";
  136.     }
  137.    
  138.     return 0;
  139. }
  140.  
  141.  
  142.  
  143.  
  144.  
  145. https://codeforces.com/problemset/problem/984/A
  146.  
  147. #include <bits/stdc++.h>
  148.  
  149. using namespace std;
  150.  
  151. int main() {
  152.    
  153.     int n;
  154.     cin >> n;
  155.     vector<int> a(n);
  156.     for (int i = 0; i < n; i++) cin >> a[i];
  157.     sort(a.rbegin(), a.rend());
  158.     cout << a[n / 2];
  159.    
  160.     return 0;
  161. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement