답안 #314855

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
314855 2020-10-21T13:50:29 Z neki Ispit (COCI19_ispit) C++14
90 / 90
1265 ms 1272 KB
#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;
}
# 결과 실행 시간 메모리 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 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 76 ms 504 KB Output is correct
2 Correct 36 ms 384 KB Output is correct
3 Correct 82 ms 504 KB Output is correct
4 Correct 32 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 72 ms 384 KB Output is correct
2 Correct 25 ms 384 KB Output is correct
3 Correct 77 ms 472 KB Output is correct
4 Correct 61 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 72 ms 384 KB Output is correct
2 Correct 43 ms 384 KB Output is correct
3 Correct 82 ms 384 KB Output is correct
4 Correct 50 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 72 ms 524 KB Output is correct
2 Correct 31 ms 384 KB Output is correct
3 Correct 77 ms 384 KB Output is correct
4 Correct 67 ms 476 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1039 ms 1164 KB Output is correct
2 Correct 684 ms 1144 KB Output is correct
3 Correct 1265 ms 1272 KB Output is correct
4 Correct 851 ms 1144 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1033 ms 1144 KB Output is correct
2 Correct 98 ms 1024 KB Output is correct
3 Correct 1083 ms 1144 KB Output is correct
4 Correct 944 ms 1024 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1042 ms 1144 KB Output is correct
2 Correct 634 ms 1104 KB Output is correct
3 Correct 1151 ms 1144 KB Output is correct
4 Correct 980 ms 1112 KB Output is correct