답안 #114444

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
114444 2019-06-01T10:43:52 Z Meloric Lottery (CEOI18_lot) C++14
0 / 100
3000 ms 1332 KB
#include <bits/stdc++.h>
#define pb push_back
#define X first
#define Y second
#define pii pair<int, int>
#define lb lower_bound

using namespace std;

int n, len, q;
vector<int> in, stupid;
vector<pii> place;
vector<vector<int>> ans, pref;

vector<int> dif(int l){
    vector<int> ret(q);
    ret[0]--;
    for(int i = 0; i< n-len+1; i++){
        int cur = 0;
        for(int j = 0; j < len; j++){
            if(in[i+j]!=in[l+j]){
                cur++;
            }
        }
        if(cur<=stupid[0]){
            ret[0]++;
        }
        /*
        int ind = lb(stupid.begin(), stupid.end(), cur)-stupid.begin();
        if(ind == q)continue;
        ret[ind]++;*/
    }
    for(int i = 1; i < q; i++){
        ret[i]+=ret[i-1];
    }
    return ret;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> len;
    for(int i=0; i < n; i++){
        int c; cin >> c;
        in.pb(c);
    }
    cin >> q;
    for(int i =0; i < q; i++){
        int c; cin >> c;
        place.pb({c, i});
        stupid.pb(c);
    }
    sort(place.begin(), place.end());
    sort(stupid.begin(), stupid.end());
    ans.assign(q, vector<int>());
    pref.assign(n-len+1, vector<int>());

    for(int i = 0; i < n-len+1; i++){
        pref[i] = dif(i);
    }
    for(int i =0; i< q; i++){
        for(int j = 0; j < n-len+1; j++){
            ans[place[i].Y].pb(pref[j][i]);
        }
    }
    for(int i = 0; i< q; i++){
        for(int j=0; j < n-len+1; j++){
            cout << ans[i][j] << ' ';
        }
        cout << '\n';
    }
    return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Incorrect 2 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Incorrect 2 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 866 ms 1096 KB Output is correct
2 Correct 1694 ms 1332 KB Output is correct
3 Correct 596 ms 1016 KB Output is correct
4 Execution timed out 3013 ms 880 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 866 ms 1096 KB Output is correct
2 Correct 1694 ms 1332 KB Output is correct
3 Correct 596 ms 1016 KB Output is correct
4 Execution timed out 3013 ms 880 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Incorrect 2 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -