Submission #96992

# Submission time Handle Problem Language Result Execution time Memory
96992 2019-02-13T08:10:33 Z Danylo99 Ispit (COCI19_ispit) C++17
45 / 90
174 ms 760 KB
#include <bits/stdc++.h>
#define ll long long
#define LL long long
#define PB push_back
#define INF 2000000000
#define X first
#define Y second
using namespace std;
const LL mod = 998244353;
const LL MAX = 600005;
string s[505];
int diff[26];
int diff2[26];
 
int main()
{
    //freopen("input.txt" , "r" , stdin);
    ios_base::sync_with_stdio(0);
    int n , k;
    cin >> n >> k;
    for(int i = 0; i < n; i++)
    {    
        cin >> s[i];
        for(auto &x : s[i])
            x -= 'a';
    }
    for(int i = 0; i < n; i++)
    {
        for(int j = i + 1; j < n; j++)
        {
            memset(diff2 , 0 , sizeof diff2);
            for(int k = 0; k < n; k++)
            {
                diff2[s[i][k]]-- , diff2[s[j][k]]++;
            }
            bool bad = false;
            for(int k = 0; k < 26; k++)
                bad |= diff2[k];
            if(bad)
                continue;
            memset(diff , 0 , sizeof diff);
            int cnt = 0;
            for(int k = 0; k < n; k++)
            {
                if(s[i][k] != s[j][k])
                {
                    cnt++;
                    diff[s[i][k]]++;
                    diff[s[j][k]]--;
                }
            }
	
            for(int i = 0; i < 26; i++)
               	bad |= diff[i];
		if(bad)
			continue;
            if(cnt > k)
                continue;
            cout << "DA";
            return 0;
        }
    }
    cout << "NE";
}

Compilation message

ispit.cpp: In function 'int main()':
ispit.cpp:34:30: warning: array subscript has type 'char' [-Wchar-subscripts]
                 diff2[s[i][k]]-- , diff2[s[j][k]]++;
                              ^
ispit.cpp:34:49: warning: array subscript has type 'char' [-Wchar-subscripts]
                 diff2[s[i][k]]-- , diff2[s[j][k]]++;
                                                 ^
ispit.cpp:48:33: warning: array subscript has type 'char' [-Wchar-subscripts]
                     diff[s[i][k]]++;
                                 ^
ispit.cpp:49:33: warning: array subscript has type 'char' [-Wchar-subscripts]
                     diff[s[j][k]]--;
                                 ^
ispit.cpp:53:13: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
             for(int i = 0; i < 26; i++)
             ^~~
ispit.cpp:55:3: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   if(bad)
   ^~
# 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 384 KB Output is correct
4 Correct 2 ms 384 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 Incorrect 2 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 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 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 384 KB Output is correct
2 Correct 7 ms 384 KB Output is correct
3 Incorrect 3 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 11 ms 384 KB Output is correct
2 Correct 8 ms 384 KB Output is correct
3 Correct 19 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 384 KB Output is correct
2 Correct 7 ms 384 KB Output is correct
3 Incorrect 3 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 9 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 13 ms 384 KB Output is correct
4 Correct 3 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 100 ms 652 KB Output is correct
2 Correct 75 ms 640 KB Output is correct
3 Incorrect 4 ms 640 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 104 ms 640 KB Output is correct
2 Correct 46 ms 760 KB Output is correct
3 Correct 174 ms 656 KB Output is correct
4 Correct 4 ms 640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 101 ms 652 KB Output is correct
2 Correct 21 ms 640 KB Output is correct
3 Incorrect 3 ms 640 KB Output isn't correct
4 Halted 0 ms 0 KB -