Submission #159276

#TimeUsernameProblemLanguageResultExecution timeMemory
159276sochoIspit (COCI19_ispit)C++14
90 / 90
628 ms1144 KiB
#include "bits/stdc++.h" using namespace std; bool comp(string a, string b) { int aoc[26], boc[26]; memset(aoc, 0, sizeof aoc); memset(boc, 0, sizeof boc); for (int i=0; i<a.size(); i++) { aoc[a[i]-'a']++; boc[b[i]-'a']++; } for (int i=0; i<26; i++) { if (aoc[i] != boc[i]) return false; } return true; } int main() { int n, k; cin >> n >> k; string arr[n]; for (int i=0; i<n; i++) { cin >> arr[i]; } int mn = INT_MAX; for (int i=0; i<n; i++) { for (int j=i+1; j<n; j++) { if (comp(arr[i], arr[j])) { int leftmis = INT_MAX; int rightmis = INT_MIN; for (int k=0; k<n; k++) { if (arr[i][k] != arr[j][k]) { leftmis = min(leftmis, k); rightmis = max(rightmis, k); } } if (leftmis == INT_MAX) { mn = 0; } else { mn = min(mn, rightmis-leftmis+1); } } } } if (mn <= k) { cout << "DA" << endl; } else { cout << "NE" << endl; } }

Compilation message (stderr)

ispit.cpp: In function 'bool comp(std::__cxx11::string, std::__cxx11::string)':
ispit.cpp:7:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i=0; i<a.size(); i++) {
                ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...