답안 #314650

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
314650 2020-10-20T14:47:37 Z ronnith Ispit (COCI19_ispit) C++14
63 / 90
2000 ms 54392 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define boost_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define int long long
#define num(a) a-'0'
#define charr(a) (a - 'A' + 1)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define maxs(a,b) if(b>a)a=b
#define mins(a,b) if(b<a)a=b
#define bin1(a) __builtin_popcount(a)
#define debug(x) cerr<<"["<<#x<<":"<<x<<"] "
#define debug2(a,b) debug(a);debug(b)
#define debug3(a,b,c) debug2(a,b);debug(c)
#define de cerr
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/(__gcd(a,b))
#define print(arr) for(auto it = arr.begin();it < arr.end();it ++){cout << *it << " ";}cout << ln;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define all(a) (a).begin(), (a).end()
#define vi vector<long long>
#define v vector
#define p pair
#define pii p<int,int>
#define pb push_back
#define mk make_pair
#define f first
#define s second
#define ln "\n"
typedef long double ld;
typedef double d;
using namespace std;
using namespace __gnu_pbds;
int modF=1e9+7;

/*OUTPUT

*/

void solve(){
	int n,k;
	cin >> n >> k;
	v<v<char>> a(n,v<char>(n));
	for(int i = 0;i < n;i ++){
		for(int j = 0;j < n;j ++){
			cin >> a[i][j];
		}
	}
	v<v<vi>> pre(26,v<vi>(n,vi(n)));
	for(int ch = 0;ch < 26;ch ++)
		for(int i = 0;i < n;i ++){
			for(int j = 0;j < n;j ++){
				char chr = (char)(ch + 97);
				if(a[i][j] == chr)
					pre[ch][i][j] = 1;
				else pre[ch][i][j] = 0;
				if(j != 0){
					pre[ch][i][j] += pre[ch][i][j - 1];
				}
			}
		}
	for(int i = 0;i <= n - k;i ++){
		for(int j = 0;j < n;j ++){
			for(int l = j + 1;l < n;l ++){
				bool pos = true;
				for(int it = 0;it < i;it ++){
					if(a[j][it] != a[l][it]){
						pos = false;
					}
				}
				for(int it = i + k;it < n;it ++){
					if(a[j][it] != a[l][it]){
						pos = false;
					}
				}
				for(int ch = 0;ch < 26;ch ++){
					int h1 = pre[ch][j][i + k - 1];
					if(i - 1 >= 0){
						h1 -= pre[ch][j][i - 1];
					}
					int h2 = pre[ch][l][i + k - 1];
					if(i - 1 >= 0)
						h2 -= pre[ch][l][i - 1];
					if(h1 != h2)pos = false;
				}
				if(pos){
					cout << "DA\n";
					return;
				}
			}
		}
	}
	cout << "NE\n";
}

signed main(){
  boost_io;
  int t=1;
  // cin>>t;
  while(t--){
    solve();
  }
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 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 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 36 ms 9088 KB Output is correct
2 Correct 60 ms 9088 KB Output is correct
3 Correct 774 ms 9208 KB Output is correct
4 Correct 683 ms 9212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 9088 KB Output is correct
2 Correct 38 ms 9088 KB Output is correct
3 Correct 460 ms 9208 KB Output is correct
4 Correct 56 ms 9088 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 42 ms 9088 KB Output is correct
2 Correct 20 ms 9088 KB Output is correct
3 Correct 264 ms 9132 KB Output is correct
4 Correct 34 ms 9088 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 9088 KB Output is correct
2 Correct 10 ms 9088 KB Output is correct
3 Correct 613 ms 9088 KB Output is correct
4 Correct 293 ms 9088 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 432 ms 54264 KB Output is correct
2 Correct 566 ms 54264 KB Output is correct
3 Execution timed out 2045 ms 54136 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 436 ms 54136 KB Output is correct
2 Correct 66 ms 54136 KB Output is correct
3 Execution timed out 2085 ms 54136 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 305 ms 54392 KB Output is correct
2 Correct 725 ms 54140 KB Output is correct
3 Execution timed out 2085 ms 54136 KB Time limit exceeded
4 Halted 0 ms 0 KB -