Submission #314855

#TimeUsernameProblemLanguageResultExecution timeMemory
314855nekiIspit (COCI19_ispit)C++14
90 / 90
1265 ms1272 KiB
#include <bits/stdc++.h> #define loop(i, a, b) for(long long i=a;i<b;i++) #define pool(i, a, b) for(long long i=a-1;i>=b;i--) #define fore(i, a) for(auto&& i:a) #define fi first #define se second #define ps(a) push_back(a) #define pb(a) pop_back(a) #define sc scanf #define vc vector #define pa pair<ll, ll> #define ll long long #define lb lower_bound #define ub upper_bound #define all(a) a.begin(), a.end() #define llmax LLONG_MAX/2 #define llmin -LLONG_MAX/2 using namespace std; #define mn 510 #define pa pair<ll, ll> #define ld long double ll can[mn], canb[mn]; string arr[mn]; int main(){ ll n, k;cin >> n >>k; loop(i, 1, n+1) cin >> arr[i]; loop(i, 1, n+1){ loop(j, 1, i){ ll cnt[26], cur=0;loop(z, 0, 26) cnt[z]=0; can[0]=1, canb[n+1]=1; loop(z, 1, n+1) can[z]=can[z-1] and (arr[i].at(z-1)==arr[j].at(z-1)); pool(z, n+1, 1) canb[z]=canb[z+1] and (arr[i].at(z-1)==arr[j].at(z-1)); loop(z, 1, n+1){ if(cnt[arr[i].at(z-1)-'a']==0) cur++; if(cnt[arr[i].at(z-1)-'a']==-1) cur--; cnt[arr[i].at(z-1)-'a']++; if(cnt[arr[j].at(z-1)-'a']==0) cur++; if(cnt[arr[j].at(z-1)-'a']==1) cur--; cnt[arr[j].at(z-1)-'a']--; if(z>=k and !cur and canb[z+1] and can[z-k]){ cout << "DA"<<endl; return 0; } } } } cout << "NE"<<endl; return 0; }
#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...