Submission #562276

# Submission time Handle Problem Language Result Execution time Memory
562276 2022-05-14T08:48:07 Z AGE Sajam (COCI18_sajam) C++14
15 / 90
41 ms 34420 KB
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define int long long
using namespace std;
const int N=1e6,M=2e3,mod=1e9+7;
string s[N];
int dp[M][M][2][2],col[M],row[M],p[N];
int root(int x){
    if(p[x]==x)
        return p[x]=x;

    return p[x]=root(p[x]);
}

void onion(int x,int y){

    x=root(x);
    y=root(y);

    if(x==y)
        return ;

    p[y]=x;

}

main()
{
    int n,m;
    cin>>n>>m;

    for(int i=0;i<n;i++)
        cin>>s[i];


   /* for(int i=0;i<n;i++)
        for(int j=0;j<s[i].size();j++)

            if(s[i][j]=='x')
                col[j][0]=1;
            else
                col[j][1]=1;
*/

    for(int j=0;j<n;j++)
        p[j]=j;

    int z=n,o=n;
    for(int i=0;i<n;i++){

        for(int j=0;j<s[i].size();j++){

            if(s[i][j]=='x')
                z=min(j,z),onion(z,j);

            else
                o=min(o,j),onion(o,j);

        }


        if(i==0)
            break;
    }

    int ok=0;

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(s[i][j]!=s[i][root(j)])
                ok=1;
        }
    }

    if(ok==1)
        cout<<"NE"<<endl;

    else cout<<"DA"<<endl;


    return 0;
}

Compilation message

sajam.cpp:29:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   29 | main()
      | ^~~~
sajam.cpp: In function 'int main()':
sajam.cpp:53:22: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |         for(int j=0;j<s[i].size();j++){
      |                     ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 15 ms 31572 KB Output is correct
2 Correct 19 ms 31956 KB Output is correct
3 Correct 21 ms 32280 KB Output is correct
4 Correct 33 ms 33288 KB Output is correct
5 Correct 22 ms 32380 KB Output is correct
6 Correct 19 ms 31892 KB Output is correct
7 Correct 21 ms 32276 KB Output is correct
8 Correct 34 ms 33248 KB Output is correct
9 Correct 16 ms 31636 KB Output is correct
10 Correct 34 ms 33308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 31572 KB Output is correct
2 Incorrect 15 ms 31572 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 28 ms 32872 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 33 ms 33196 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 32564 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 41 ms 34420 KB Output isn't correct
2 Halted 0 ms 0 KB -