답안 #313950

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
313950 2020-10-17T14:27:05 Z phathnv Ispit (COCI19_ispit) C++11
45 / 90
333 ms 892 KB
#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

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);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Incorrect 1 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 384 KB Output is correct
2 Correct 12 ms 384 KB Output is correct
3 Incorrect 1 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 384 KB Output is correct
2 Correct 20 ms 504 KB Output is correct
3 Correct 19 ms 512 KB Output is correct
4 Correct 1 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 384 KB Output is correct
2 Correct 15 ms 512 KB Output is correct
3 Incorrect 1 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 508 KB Output is correct
2 Correct 3 ms 512 KB Output is correct
3 Correct 19 ms 384 KB Output is correct
4 Correct 1 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 328 ms 872 KB Output is correct
2 Correct 244 ms 768 KB Output is correct
3 Incorrect 2 ms 768 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 333 ms 888 KB Output is correct
2 Correct 111 ms 888 KB Output is correct
3 Correct 276 ms 888 KB Output is correct
4 Correct 2 ms 768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 332 ms 848 KB Output is correct
2 Correct 57 ms 892 KB Output is correct
3 Incorrect 2 ms 768 KB Output isn't correct
4 Halted 0 ms 0 KB -