Submission #147510

# Submission time Handle Problem Language Result Execution time Memory
147510 2019-08-29T21:24:08 Z ipaljak Ispit (COCI19_ispit) C++14
90 / 90
196 ms 888 KB
#include <bits/stdc++.h>

using namespace std;

#define TRACE(x) cerr << #x << " " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<

typedef long long llint;

const int MOD = 1e9 + 7;
const int MAXN = 505;

int n, k;
char s[MAXN][MAXN];

int main(void) {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; ++i) scanf("%s", s[i]);

  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      int lo = n - 1, hi = 0;
      for (int k = 0; k < n; ++k) {
        if (s[i][k] == s[j][k]) continue;
        lo = min(lo, k); hi = max(hi, k);
      }
      if (hi - lo + 1 > k) continue;
      int cnti[26], cntj[26];
      memset(cnti, 0, sizeof cnti);
      memset(cntj, 0, sizeof cntj);
      for (int k = lo; k <= hi; ++k) {
        cnti[s[i][k] - 'a']++;
        cntj[s[j][k] - 'a']++;
      }
      bool check = true;
      for (int k = 0; k < 26; ++k)
        check &= cnti[k] == cntj[k];
      if (check) {
        printf("DA\n");
        return 0;
      }
    }
  }

  printf("NE\n");
  return 0;
}

Compilation message

ispit.cpp: In function 'int main()':
ispit.cpp:19:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &n, &k);
   ~~~~~^~~~~~~~~~~~~~~~
ispit.cpp:20:36: 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", s[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 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
# 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 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 380 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 15 ms 376 KB Output is correct
2 Correct 9 ms 504 KB Output is correct
3 Correct 11 ms 376 KB Output is correct
4 Correct 7 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 45 ms 376 KB Output is correct
2 Correct 12 ms 376 KB Output is correct
3 Correct 9 ms 504 KB Output is correct
4 Correct 9 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 376 KB Output is correct
2 Correct 11 ms 376 KB Output is correct
3 Correct 8 ms 376 KB Output is correct
4 Correct 8 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 376 KB Output is correct
2 Correct 4 ms 504 KB Output is correct
3 Correct 9 ms 504 KB Output is correct
4 Correct 10 ms 496 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 196 ms 632 KB Output is correct
2 Correct 147 ms 604 KB Output is correct
3 Correct 71 ms 504 KB Output is correct
4 Correct 89 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 196 ms 604 KB Output is correct
2 Correct 78 ms 504 KB Output is correct
3 Correct 108 ms 504 KB Output is correct
4 Correct 132 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 196 ms 508 KB Output is correct
2 Correct 37 ms 760 KB Output is correct
3 Correct 107 ms 888 KB Output is correct
4 Correct 86 ms 856 KB Output is correct