# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
159276 |
2019-10-22T00:48:21 Z |
socho |
Ispit (COCI19_ispit) |
C++14 |
|
628 ms |
1144 KB |
#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
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 time |
Memory |
Grader output |
1 |
Correct |
2 ms |
380 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
420 KB |
Output is correct |
4 |
Correct |
2 ms |
252 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
380 KB |
Output is correct |
2 |
Correct |
38 ms |
480 KB |
Output is correct |
3 |
Correct |
46 ms |
484 KB |
Output is correct |
4 |
Correct |
41 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
376 KB |
Output is correct |
2 |
Correct |
38 ms |
408 KB |
Output is correct |
3 |
Correct |
40 ms |
376 KB |
Output is correct |
4 |
Correct |
43 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
376 KB |
Output is correct |
2 |
Correct |
36 ms |
376 KB |
Output is correct |
3 |
Correct |
42 ms |
484 KB |
Output is correct |
4 |
Correct |
40 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
504 KB |
Output is correct |
2 |
Correct |
37 ms |
504 KB |
Output is correct |
3 |
Correct |
40 ms |
376 KB |
Output is correct |
4 |
Correct |
44 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
502 ms |
1096 KB |
Output is correct |
2 |
Correct |
509 ms |
1144 KB |
Output is correct |
3 |
Correct |
571 ms |
1144 KB |
Output is correct |
4 |
Correct |
602 ms |
1144 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
511 ms |
1016 KB |
Output is correct |
2 |
Correct |
528 ms |
1144 KB |
Output is correct |
3 |
Correct |
554 ms |
1016 KB |
Output is correct |
4 |
Correct |
626 ms |
1144 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
518 ms |
1104 KB |
Output is correct |
2 |
Correct |
505 ms |
1104 KB |
Output is correct |
3 |
Correct |
628 ms |
1116 KB |
Output is correct |
4 |
Correct |
558 ms |
1144 KB |
Output is correct |