Submission #313950

#TimeUsernameProblemLanguageResultExecution timeMemory
313950phathnvIspit (COCI19_ispit)C++11
45 / 90
333 ms892 KiB
#include <bits/stdc++.h> #define mp make_pair #define X first #define Y second #define taskname "ISPIT" using namespace std; typedef long long ll; typedef pair <int, int> ii; const int N = 502; int n, k; char a[N][N]; int d[26]; void readInput(){ scanf("%d %d", &n, &k); for(int i = 1; i <= n; i++) scanf("%s", a[i] + 1); } bool check(int x1, int x2){ for(int i = 0; i < 26; i++) d[i] = 0; int cnt = 0; for(int i = 1; i <= n; i++) if (a[x1][i] != a[x2][i]){ cnt++; d[a[x1][i] - 'a']++; d[a[x2][i] - 'a']--; } if (cnt > k) return 0; for(int i = 0; i < 26; i++) if (d[i] != 0) return 0; return 1; } void solve(){ for(int x1 = 1; x1 <= n; x1++) for(int x2 = x1 + 1; x2 <= n; x2++) if (check(x1, x2)){ printf("DA"); return; } printf("NE"); } int main(){ if (fopen(taskname".inp", "r")){ freopen(taskname".inp", "r", stdin); freopen(taskname".out", "w", stdout); } readInput(); solve(); return 0; }

Compilation message (stderr)

ispit.cpp: In function 'void readInput()':
ispit.cpp:20:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   20 |     scanf("%d %d", &n, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~
ispit.cpp:22:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   22 |         scanf("%s", a[i] + 1);
      |         ~~~~~^~~~~~~~~~~~~~~~
ispit.cpp: In function 'int main()':
ispit.cpp:55:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   55 |         freopen(taskname".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
ispit.cpp:56:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   56 |         freopen(taskname".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...