Submission #636748

# Submission time Handle Problem Language Result Execution time Memory
636748 2022-08-30T02:48:21 Z iee Ispit (COCI19_ispit) C++17
90 / 90
139 ms 852 KB
// iee
#include <bits/stdc++.h>

#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)
#define fi first
#define se second
using ll = long long;
using ull = unsigned long long;
using namespace std;
void work(int);

template <class T> void read(T &x) {
  x = 0;
  int f = 1, ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + (ch - '0');
    ch = getchar();
  }
  x *= f;
}

int main() {
  int TT = 1; // cin >> TT;
  rep(CAS, 1, TT)
    work(CAS);
  return 0;
}
const int N = 505;
int n, k;
char s[N][N];
int cnt[26];
bool chk(int x, int y) {
  int l = -1, r = -1;
  rep(i, 1, n) if (s[x][i] != s[y][i]) {
    if (l == -1) l = i;
    r = i;
  }
  if (l == -1) return 1;
  if (r - l + 1 > k) return 0;
  memset(cnt, 0, sizeof cnt);
  rep(i, 1, n) cnt[s[x][i] - 'a']++;
  rep(i, 1, n) cnt[s[y][i] - 'a']--;
  rep(i, 0, 25) if (cnt[i]) return 0;
  return 1;
}
void work(int CASE) {
  read(n), read(k);
  rep(i, 1, n) scanf("%s", s[i] + 1);
  rep(i, 1, n) rep(j, i + 1, n) if (chk(i, j)) { puts("DA"); return; }
  puts("NE");
}

Compilation message

ispit.cpp: In function 'void work(int)':
ispit.cpp:53:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   53 |   rep(i, 1, n) scanf("%s", s[i] + 1);
      |                ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 284 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 308 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 340 KB Output is correct
2 Correct 6 ms 444 KB Output is correct
3 Correct 9 ms 440 KB Output is correct
4 Correct 4 ms 440 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 36 ms 424 KB Output is correct
2 Correct 7 ms 340 KB Output is correct
3 Correct 5 ms 340 KB Output is correct
4 Correct 6 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 444 KB Output is correct
2 Correct 6 ms 376 KB Output is correct
3 Correct 5 ms 340 KB Output is correct
4 Correct 4 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 340 KB Output is correct
2 Correct 3 ms 340 KB Output is correct
3 Correct 5 ms 340 KB Output is correct
4 Correct 9 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 123 ms 776 KB Output is correct
2 Correct 99 ms 772 KB Output is correct
3 Correct 63 ms 780 KB Output is correct
4 Correct 49 ms 776 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 139 ms 724 KB Output is correct
2 Correct 55 ms 852 KB Output is correct
3 Correct 59 ms 684 KB Output is correct
4 Correct 100 ms 776 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 133 ms 776 KB Output is correct
2 Correct 22 ms 724 KB Output is correct
3 Correct 85 ms 776 KB Output is correct
4 Correct 46 ms 776 KB Output is correct