답안 #114440

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
114440 2019-06-01T10:35:39 Z Meloric Lottery (CEOI18_lot) C++14
45 / 100
3000 ms 1400 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++;
            }
        }
        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 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 6 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 512 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 5 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 6 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 512 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 5 ms 512 KB Output is correct
13 Correct 48 ms 508 KB Output is correct
14 Correct 590 ms 796 KB Output is correct
15 Correct 665 ms 892 KB Output is correct
16 Correct 437 ms 888 KB Output is correct
17 Correct 529 ms 896 KB Output is correct
18 Correct 515 ms 1032 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1004 ms 1268 KB Output is correct
2 Correct 1920 ms 1400 KB Output is correct
3 Correct 803 ms 1188 KB Output is correct
4 Execution timed out 3027 ms 1144 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1004 ms 1268 KB Output is correct
2 Correct 1920 ms 1400 KB Output is correct
3 Correct 803 ms 1188 KB Output is correct
4 Execution timed out 3027 ms 1144 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 6 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 512 KB Output is correct
11 Correct 4 ms 384 KB Output is correct
12 Correct 5 ms 512 KB Output is correct
13 Correct 48 ms 508 KB Output is correct
14 Correct 590 ms 796 KB Output is correct
15 Correct 665 ms 892 KB Output is correct
16 Correct 437 ms 888 KB Output is correct
17 Correct 529 ms 896 KB Output is correct
18 Correct 515 ms 1032 KB Output is correct
19 Correct 1004 ms 1268 KB Output is correct
20 Correct 1920 ms 1400 KB Output is correct
21 Correct 803 ms 1188 KB Output is correct
22 Execution timed out 3027 ms 1144 KB Time limit exceeded
23 Halted 0 ms 0 KB -