90B - African Crossword - CodeForces Solution


implementation strings *1100

Please click on ads to support us..

C++ Code:

#include<bits/stdc++.h>
#define ll long long
#define w "YES\n"
#define n "NO\n"
#define en endl
#define agaarki if
#define tovaqteki for
#define qq long long q; cin>>q; for(int i=0;i<q;i++)
#define fx fixed<<setprecision(9)
#define iqBoost ios_base::sync_with_stdio(false), cin.tie(0);
using namespace std;
main()
{
    //B. ����������� ���������
    string s;
    int a,b;
    cin>>a>>b;
    char ar[a][b];
    for(int i=0; i<a; i++)
        for(int j=0; j<b; j++)
            cin>>ar[i][j];
    for(int i=0; i<a; i++)
        for(int j=0; j<b; j++)
        {
            int g=0;
            for(int x=1; x<=max(a,b); x++)
            {
                if(i+x<a and ar[i][j]==ar[i+x][j])
                    g++;
                if(j+x<b and ar[i][j]==ar[i][j+x])
                    g++;
                if( i-x>=0 and ar[i][j]==ar[i-x][j])
                    g++;
                if(j-x>=0 and ar[i][j]==ar[i][j-x])
                    g++;
            }
            if(g==0)
                s+=ar[i][j];
        }
    cout<<s;


}
/**
{
    //A. ����������������� ������������ ���������������������
    string s;
    cin>>s;
    string g=s;
    sort(g.rbegin(),g.rend());
    string d;
    int pos=0;
    for(int i=0; i<s.size(); i++)
    {
        if(s[i]==g[pos] || i==s.size()-1)
        {
            d+=s[i];
            pos++;
        }
    }
    cout<<d;
}
/**
abbcbccacbbcbaaba
cccccbbbbbbbaaaaa
{
    //B. ���������� ����
    string s,s1;
    cin>>s;
    char c='a';
    for(int i=0;i<s.size();i++)
    {
        if(s1.find(s[i])==-1 )
        {
            if(c==s[i]){
            c=char(c+1);
            s1+=s[i];
            }
            else
                return cout<<"NO",0;
        }
    }
    cout<<"YES";
}
/**
 /////A. ������� ������� ������
bool is_palindrom(string s)
{
    for(int l=0,r=s.size()-1;l<s.size();l++,r--)
    {
        if(s[l]!=s[r])
            return false;
    }
    return true;
}
main()
{
    string s,s1;
    cin>>s;
    for(int i=0;i<s.size();i++)
    {
        if(s1.find(s[i])==-1)
            s1+=s[i];
    }
    for(int h=0;h<s1.size();h++)
    for(int i=0;i<s.size();i++)
    {
        string m;
        for(int j=0;j<i;j++)
            m+=s[j];
        m+=s1[h];
        for(int j=i;j<s.size();j++)
            m+=s[j];
        if(is_palindrom(m)==true)
            return cout<<m,0;
    }
    for(int h=0;h<s1.size();h++)
    {
        string i=s+s1[h];
                if(is_palindrom(i)==true)
            return cout<<i,0;
    }
    cout<<"NA";
}
/**
{
    //B. ��������-�����
    string s;
    cin>>s;
    if(s[0]=='h'){
        cout<<"http://";
        s.erase(s.begin()+0);
        s.erase(s.begin()+0);
        s.erase(s.begin()+0);
        s.erase(s.begin()+0);}
    else
    {
        cout<<"ftp://";
        s.erase(s.begin()+0);
        s.erase(s.begin()+0);
        s.erase(s.begin()+0);
    }
    int p=-1;
    for(int i=0;i<s.size()-1;i++)
    {
        if(s[i]=='r' and s[i+1]=='u')
            p=i;
    }
    for(int i=0;i<p;i++)
        cout<<s[i];
    cout<<".ru";
    if(p!=s.size()-2)
    {
        cout<<'/';
        for(int i=p+2;i<s.size();i++)
            cout<<s[i];
    }

}

/**
asdasd
012345
10
6 9 4 7 8 2 3 5 0 1
 ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

I will succes !

freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);


         **--------------------**
           RESHETOI AKAI MUSLIM
    vector < bool >prime(N, true);
    for(ll i = 2; i <= 1000000; i ++) {
        if(!prime[i]) {
            continue;
        }
        for(ll j = i * i; j <= 1000000; j += i) {
            prime[j] = false;
        }
    }
B.Shahrom
k.ibrohim
Z.muhammad
k.ismoil
---ME---
**/


Comments

Submit
0 Comments
More Questions

22A - Second Order Statistics
1720B - Interesting Sum
1720A - Burenka Plays with Fractions
3A - Shortest path of the king
1720C - Corners
574A - Bear and Elections
352B - Jeff and Periods
1244A - Pens and Pencils
1670A - Prof Slim
1189A - Keanu Reeves
678A - Johny Likes Numbers
1699C - The Third Problem
1697D - Guess The String
754B - Ilya and tic-tac-toe game
760A - Petr and a calendar
1573A - Countdown
166A - Rank List
1631B - Fun with Even Subarrays
727A - Transformation from A to B
822B - Crossword solving
1623A - Robot Cleaner
884B - Japanese Crosswords Strike Back
862B - Mahmoud and Ehab and the bipartiteness
429A - Xor-tree
1675C - Detective Task
950A - Left-handers Right-handers and Ambidexters
672B - Different is Good
1C - Ancient Berland Circus
721A - One-dimensional Japanese Crossword
1715B - Beautiful Array