답안 #96606

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
96606 2019-02-10T11:54:52 Z heon Ispit (COCI19_ispit) C++11
9 / 90
274 ms 35220 KB
#include<bits/stdc++.h>

using namespace std;

#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;

const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;

bool isti[205][205][205][2];
string temp[505][2], s[505];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif*/

	int n, k;
	cin >> n >> k;
	for(int i = 0; i < n; i++){
		cin >> s[i];
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			temp[j][0] += s[j][i];
		}
		for(int j = 0; j < n; j++){
			for(int l = j + 1; l < n; l++){
				isti[i][j][l][0] = (temp[j][0] == temp[l][0]);
			}
		}
	}
	for(int i = n - 1; i >= 0; i--){
		for(int j = 0; j < n; j++){
			temp[j][1] += s[j][i];
		}
		for(int j = 0; j < n; j++){
			for(int l = j + 1; l < n; l++){
				isti[i][j][l][1] = (temp[j][1] == temp[l][1]);
			}
		}		
	}
	for(int i = 0; i <= n - k; i++){
		int cnt[505][26] = {};
		for(int j = 0; j < n; j++){
			for(int l = 0; l < k; l++){
				cnt[j][s[j][l + i] - 'a']++;
			}
		}
		for(int j = 0; j < n; j++){
			bool ok = 1;
			for(int l = j + 1; l < n; l++){
				for(int x = 0; x < 26; x++){
					if(cnt[j][x] != cnt[l][x]){
						ok = 0;
						break;
					}
				}
				if(!ok) break;
				else{
					bool desno = 1, lijevo = 1;
					if(i){
						lijevo = isti[i - 1][j][l][0];
					}
					if(i != n - k){
						desno = isti[n - i][j][l][1];
					}
					if(desno && lijevo) return cout << "DA",0;
				}
			}
		}
	}
	cout << "NE";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 504 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Incorrect 2 ms 504 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 632 KB Output is correct
2 Incorrect 2 ms 504 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 85 ms 17028 KB Output is correct
2 Incorrect 82 ms 17016 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 81 ms 17024 KB Output is correct
2 Incorrect 85 ms 17088 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 79 ms 17144 KB Output is correct
2 Incorrect 84 ms 17032 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 80 ms 17144 KB Output is correct
2 Incorrect 86 ms 17020 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 274 ms 35004 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 260 ms 35048 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 247 ms 35220 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -