Showing posts with label Codeforce A. Show all posts
Showing posts with label Codeforce A. Show all posts

Monday, September 16, 2019

Codeforce A. DZY Loves Chessboard

  1. #include< bits/stdc++.h >
  2. using namespace std;
  3. int main(){
  4. int n, m, b = 0, w = 0;
  5. cin >> n >> m;
  6. char data[n][m];
  7. for(int i = 0; i < n; i++) {
  8. for(int j = 0; j < m; j++) {
  9. cin >> data[i][j];
  10. }
  11. }
  12. for(int i = 0; i < n; i++) {
  13. for(int j = 0; j < m; j++) {
  14. if(data[i][j] == '.') {
  15. if((i+j) % 2) cout << 'W';
  16. else cout << 'B';
  17. }else cout << data[i][j];
  18. }
  19. cout << endl;
  20. }
  21. return 0;
  22. }

Codeforce A. Middle of the Contest

  1. #include< bits/stdc++.h >
  2. using namespace std;
  3. int main(){
  4. int h1, m1, h2, m2, ans = 0, resH = 0, resM = 0, rM;
  5. scanf("%d:%d", &h1, &m1);
  6. scanf("%d:%d", &h2, &m2);
  7. if(m1 > m2) ans = (60 - m1) + m2;
  8. else ans = (h2 - h1)*60 + (m2-m1);
  9. ans /= 2;
  10. resH = h1 + ans/60;
  11. rM = m1 + ans%60;
  12. if( rM / 60 > 0) resH += rM / 60;
  13. resM = rM%60;
  14. if(resH < 10) cout <<0;
  15. cout << resH << ":";
  16. if(resM < 10) cout << 0;
  17. cout << resM << endl;
  18. return 0;
  19. }

Codeforce A. Life Without Zeros

  1. #include< iostream >
  2. using namespace std;
  3. int withOutZero(int n){
  4. int ans = 0;
  5. while(n != 0) {
  6. if(n%10 != 0)
  7. ans = n%10 + (ans *10) ;
  8. n /= 10;
  9. }
  10. return ans;
  11. }
  12. int main(){
  13. int n, m;
  14. cin >> n >> m;
  15. if(n == m) return cout << "YES" << endl, 0;
  16. int ans = n+m;
  17. ans = withOutZero(ans);
  18. ans = withOutZero(ans);
  19. n = withOutZero(n);
  20. n = withOutZero(n);
  21. m = withOutZero(m);
  22. m = withOutZero(m);
  23. if(ans == n+m) cout << "YES" << endl;
  24. else cout << "NO" << endl;
  25. return 0;
  26. }

Codeforce A. Yaroslav and Permutations

  1. #include< iostream >
  2. using namespace std;
  3. int main() {
  4. int n, x;
  5. cin >> n;
  6. int ar[10001] = {0};
  7. for(int i = 0; i < n; i++) {
  8. cin >> x;
  9. ar[x]++;
  10. if(ar[x] > (n+1)/2) return cout << "NO\n", 0;
  11. }
  12. cout << "YES\n";
  13. return 0;
  14. }

Codeforce A. Collecting Beats is Fun

  1. #include< bits/stdc++.h >
  2. using namespace std;
  3. int main(){
  4. int k;
  5. char a;
  6. cin >> k;
  7. int ar[10] = {0};
  8. for(int i = 0; i < 16; i++){
  9. cin >> a;
  10. ar[a]++;
  11. }
  12. for(int i = 1; i < 10; i++)
  13. if(ar[i+'0'] > 2*k) return cout << "NO\n", 0;
  14. cout << "YES\n";
  15. return 0;
  16. }