Submission #96620

#TimeUsernameProblemLanguageResultExecution timeMemory
96620heonIspit (COCI19_ispit)C++11
9 / 90
268 ms35152 KiB
#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 l = 0; l < k; l++){ for(int j = 0; j < n; j++){ cnt[l + i][s[j][l + i] - 'a']++; } } for(int x = 0; x < 26; x++){ bool ok = 1; for(int l = 0; l < k; l++){ ok &= cnt[l + i][x] >= 1; } if(ok){ for(int xx = x; xx < 26; xx++){ for(int l = 0; l < k; l++){ if(xx == x) ok &= cnt[l + i][xx] >= 2; else ok &= cnt[l + i][xx] >= 1; } if(ok){ bool lijevo = true, desno = true; if(i){ lijevo = false; for(int z = 0; z < n; z++){ for(int y = z + 1; y < n; y++){ if(isti[i - 1][z][y][0]){ lijevo = true; break; } } } } if(i != n - k){ desno = false; for(int z = 0; z < n; z++){ for(int y = z + 1; y < n; y++){ if(isti[i + k][z][y][1]){ desno = true; break; } } } } if(desno && lijevo) return cout << "DA", 0; } ok = 1; } } } } cout << "NE"; }
#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...