답안 #100864

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
100864 2019-03-14T22:12:57 Z Ort Ispit (COCI19_ispit) C++11
90 / 90
27 ms 896 KB
#include<iostream>
#include<string>
#include<algorithm>
#define MAX 505

using namespace std;

int n, k;

string mat[MAX];
string smat[MAX];
string s;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	cin >> n >> k;
	for(int i=0;i<n;i++) {cin >> s;mat[i] = s;sort(s.begin(),s.end());smat[i] = s;}
	int cnt = 0;
	for(int i=0;i<n;i++) {
		for(int j=0;j<n;j++) {
			if(i==j) continue;
			if(smat[i]==smat[j]) {
				int a = 0, b = 0;
				for(int z=0;z<n;z++)
					if(mat[i][z]==mat[j][z]) a++;
					else break;

				for(int z=n-1;z>=0;z--)
					if(mat[i][z]==mat[j][z]) b++;
					else break;
				if(n-a-b<=k) {
					cout << "DA";
					return 0;
				}
			}
		}
	}
	cout << "NE";
	return 0;
}

Compilation message

ispit.cpp: In function 'int main()':
ispit.cpp:19:6: warning: unused variable 'cnt' [-Wunused-variable]
  int cnt = 0;
      ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 428 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 512 KB Output is correct
2 Correct 3 ms 512 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 512 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 3 ms 512 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 512 KB Output is correct
2 Correct 3 ms 512 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 896 KB Output is correct
2 Correct 11 ms 896 KB Output is correct
3 Correct 17 ms 896 KB Output is correct
4 Correct 16 ms 896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 796 KB Output is correct
2 Correct 10 ms 896 KB Output is correct
3 Correct 18 ms 896 KB Output is correct
4 Correct 27 ms 896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 896 KB Output is correct
2 Correct 9 ms 896 KB Output is correct
3 Correct 23 ms 896 KB Output is correct
4 Correct 15 ms 896 KB Output is correct