Submission #104521

# Submission time Handle Problem Language Result Execution time Memory
104521 2019-04-07T11:11:23 Z Hassoony Ispit (COCI19_ispit) C++17
90 / 90
226 ms 896 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const ll mod=(1e9+7);
const ll inf=(1ll<<61);
const int MX=502;
int n,p,c[MX];
char a[MX][MX];
int main(){
    cin>>n>>p;
    for(int i=0;i<n;i++)scanf("%s",&a[i]);
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int k='a';k<='z';k++)c[k]=0;
            int mn=MX,mx=-1;
            for(int k=0;k<n;k++){
                if(a[i][k]!=a[j][k]){
                    mn=min(mn,k);
                    mx=max(mx,k);
                    c[a[i][k]]++;
                }
            }
            if(mx-mn+1>p)continue;
            bool ok=1;
            for(int k=0;k<n;k++){
                if(a[i][k]!=a[j][k]){
                    if(c[a[j][k]])c[a[j][k]]--;
                    else ok=0;
                }
            }
            if(ok){
                puts("DA");
                return 0;
            }
        }
    }
    puts("NE");
}
/*
4 2
abcd
acbd
enaa
moze
2 2
aa
aa
3 2
nec
uuc
iti
*/

Compilation message

ispit.cpp: In function 'int main()':
ispit.cpp:12:41: warning: format '%s' expects argument of type 'char*', but argument 2 has type 'char (*)[502]' [-Wformat=]
     for(int i=0;i<n;i++)scanf("%s",&a[i]);
                                    ~~~~~^
ispit.cpp:21:30: warning: array subscript has type 'char' [-Wchar-subscripts]
                     c[a[i][k]]++;
                              ^
ispit.cpp:28:33: warning: array subscript has type 'char' [-Wchar-subscripts]
                     if(c[a[j][k]])c[a[j][k]]--;
                                 ^
ispit.cpp:28:44: warning: array subscript has type 'char' [-Wchar-subscripts]
                     if(c[a[j][k]])c[a[j][k]]--;
                                            ^
ispit.cpp:12:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=0;i<n;i++)scanf("%s",&a[i]);
                         ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 372 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 512 KB Output is correct
2 Correct 11 ms 512 KB Output is correct
3 Correct 12 ms 512 KB Output is correct
4 Correct 10 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 384 KB Output is correct
2 Correct 12 ms 512 KB Output is correct
3 Correct 12 ms 512 KB Output is correct
4 Correct 9 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 512 KB Output is correct
2 Correct 11 ms 384 KB Output is correct
3 Correct 9 ms 512 KB Output is correct
4 Correct 11 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 18 ms 512 KB Output is correct
2 Correct 5 ms 512 KB Output is correct
3 Correct 11 ms 384 KB Output is correct
4 Correct 14 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 215 ms 856 KB Output is correct
2 Correct 160 ms 888 KB Output is correct
3 Correct 68 ms 892 KB Output is correct
4 Correct 97 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 195 ms 892 KB Output is correct
2 Correct 71 ms 848 KB Output is correct
3 Correct 138 ms 892 KB Output is correct
4 Correct 142 ms 860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 226 ms 768 KB Output is correct
2 Correct 33 ms 860 KB Output is correct
3 Correct 95 ms 860 KB Output is correct
4 Correct 105 ms 896 KB Output is correct