- #include< bits/stdc++.h >
- using namespace std;
- int main(){
- int n, m, b = 0, w = 0;
- cin >> n >> m;
- char data[n][m];
- for(int i = 0; i < n; i++) {
- for(int j = 0; j < m; j++) {
- cin >> data[i][j];
- }
- }
- for(int i = 0; i < n; i++) {
- for(int j = 0; j < m; j++) {
- if(data[i][j] == '.') {
- if((i+j) % 2) cout << 'W';
- else cout << 'B';
- }else cout << data[i][j];
- }
- cout << endl;
- }
- return 0;
- }
Showing posts with label Codeforce. Show all posts
Showing posts with label Codeforce. Show all posts
Monday, September 16, 2019
Codeforce A. DZY Loves Chessboard
Codeforce A. Middle of the Contest
- #include< bits/stdc++.h >
- using namespace std;
- int main(){
- int h1, m1, h2, m2, ans = 0, resH = 0, resM = 0, rM;
- scanf("%d:%d", &h1, &m1);
- scanf("%d:%d", &h2, &m2);
- if(m1 > m2) ans = (60 - m1) + m2;
- else ans = (h2 - h1)*60 + (m2-m1);
- ans /= 2;
- resH = h1 + ans/60;
- rM = m1 + ans%60;
- if( rM / 60 > 0) resH += rM / 60;
- resM = rM%60;
- if(resH < 10) cout <<0;
- cout << resH << ":";
- if(resM < 10) cout << 0;
- cout << resM << endl;
- return 0;
- }
Codeforce A. Life Without Zeros
- #include< iostream >
- using namespace std;
- int withOutZero(int n){
- int ans = 0;
- while(n != 0) {
- if(n%10 != 0)
- ans = n%10 + (ans *10) ;
- n /= 10;
- }
- return ans;
- }
- int main(){
- int n, m;
- cin >> n >> m;
- if(n == m) return cout << "YES" << endl, 0;
- int ans = n+m;
- ans = withOutZero(ans);
- ans = withOutZero(ans);
- n = withOutZero(n);
- n = withOutZero(n);
- m = withOutZero(m);
- m = withOutZero(m);
- if(ans == n+m) cout << "YES" << endl;
- else cout << "NO" << endl;
- return 0;
- }
Codeforce A. Yaroslav and Permutations
- #include< iostream >
- using namespace std;
- int main() {
- int n, x;
- cin >> n;
- int ar[10001] = {0};
- for(int i = 0; i < n; i++) {
- cin >> x;
- ar[x]++;
- if(ar[x] > (n+1)/2) return cout << "NO\n", 0;
- }
- cout << "YES\n";
- return 0;
- }
Codeforce A. Collecting Beats is Fun
- #include< bits/stdc++.h >
- using namespace std;
- int main(){
- int k;
- char a;
- cin >> k;
- int ar[10] = {0};
- for(int i = 0; i < 16; i++){
- cin >> a;
- ar[a]++;
- }
- for(int i = 1; i < 10; i++)
- if(ar[i+'0'] > 2*k) return cout << "NO\n", 0;
- cout << "YES\n";
- return 0;
- }
Codeforce A. Levko and Table
- #include< iostream >
- using namespace std;
- int main()
- {
- int n, k;
- cin >> n >> k;
- for(int i = 0; i < n; i++) {
- for(int j = 0; j < n; j++) {
- cout << ((i == j)? k : 0 ) << " ";
- }
- cout << endl;
- }
- return 0;
- }
Codeforce A. Vasya and Digital Root
- #include< iostream >
- using namespace std;
- int main()
- {
- int k, d;
- cin >> k >> d;
- if(d == 0 and k > 1) return cout << "No solution\n", 0;
- cout << d ;
- while(--k) cout << 0 ;
- return 0;
- }
Codeforce A. Two Bags of Potatoes
- #include< iostream >
- using namespace std;
- int main()
- {
- int y, k, n;
- cin >> y >> k >> n;
- int x = k - y%k;
- if(x+y > n) return cout << -1 << endl , 0;
- for(int i = x ; i <= n-y; i+=k)
- cout << i << " ";
- return 0;
- }
Codeforce A. The Child and Homework
- #include< iostream >
- #include< cstdio >
- #include< algorithm >
- using namespace std;
- string o[4];
- int main() {
- int maxlength = 0, minlength = 110, maxindex = 0, minindex = 0;
- int c[4];
- for (int i = 0; i < 4; i++) {
- getline(cin, o[i]);
- c[i] = o[i].length() - 2;
- }
- sort(c, c + 4);
- bool hasMax = c[3] >= c[2] * 2;
- bool hasMin = c[0] <= c[1] / 2;
- if (hasMax == hasMin) {
- cout << "C";
- } else if (hasMin) {
- for (int i = 0; i < 4; i++) {
- if (c[0] + 2 == o[i].length()) {
- cout << o[i].at(0);
- }
- }
- } else if (hasMax) {
- for (int i = 0; i < 4; i++) {
- if (c[3] + 2 == o[i].length()) {
- cout << o[i].at(0);
- }
- }
- }
- return 0;
- }
Codeforce A. Soroban
- #include < bits/stdc++.h >
- using namespace std;
- int main()
- {
- int n;
- cin>>n;
- if(!n){
- cout<<"O-|-OOOO\n";
- return 0;
- }
- while(n){
- int m=n%10;
- n/=10;
- string s="--|OOOOO";
- if(m>=5)s[1]='O';
- else s[0]='O';
- s[m%5+3]='-';
- cout<<s<<endl;
- }
- }
Subscribe to:
Posts (Atom)