답안 #168979

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
168979 2019-12-17T10:46:49 Z kostia244 Lottery (CEOI18_lot) C++17
100 / 100
855 ms 6776 KB
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
using namespace std;
using ll = long long;
// using vi vector<int>;
const int maxn = 10222;
int n, l, q, x;
int a[maxn], id[maxn];
short mat[maxn], cnt[maxn][111];
vector<int> qq, uu;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> l;
    for(int i = 1; i <= n; i++) cin >> a[i];
    cin >> q;
    qq.resize(q);
    for(auto &i :qq) cin >> i;
    
    uu = qq;
    sort(all(uu));
    memset(id, -1, sizeof id);
    for(int i = q; i--;)
    	id[uu[i]]=i;
    id[n+1]=101;
    for(int i = n; i>=0; i--) {
    	if(id[i]==-1) id[i]=id[i+1];
    }
    
    
    for(int d = 1; d <= n; d++) {
		for(int i = 1,j = d+1; j <= n; j++, i++) {
			if(a[i]==a[j]) continue;
		    int L = max(j-l+1, 1+d);
		    int R = min(j, n-l+1);
		    // cout << i << " " << j << " : " << L << " " << R << "\n";
		  if(L<=R){
		    ++mat[L];
		    --mat[R+1];}
		}
        ll cur = 0;
        for(int j = d+1; j <= n-l+1; j++) {
            cur += mat[j];
            mat[j] = 0;
            ++cnt[j][id[cur]];
            ++cnt[j-d][id[cur]];
        }
    }
    for(int i = 1; i <= n-l+1; i++) {
        for(int j = 1; j <= 101; j++) {
            cnt[i][j] += cnt[i][j-1];
        }
    }
    for(auto x : qq){
        cin >> x;
        // cout << x << " " << id[x] << "\n";
        for(int i = 1; i <= n-l+1; i++) cout << cnt[i][id[x]] << " ";cout << "\n";
    }
}

Compilation message

lot.cpp: In function 'int main()':
lot.cpp:59:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
         for(int i = 1; i <= n-l+1; i++) cout << cnt[i][id[x]] << " ";cout << "\n";
         ^~~
lot.cpp:59:70: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
         for(int i = 1; i <= n-l+1; i++) cout << cnt[i][id[x]] << " ";cout << "\n";
                                                                      ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 380 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 3 ms 504 KB Output is correct
11 Correct 3 ms 504 KB Output is correct
12 Correct 3 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 380 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 3 ms 504 KB Output is correct
11 Correct 3 ms 504 KB Output is correct
12 Correct 3 ms 504 KB Output is correct
13 Correct 25 ms 888 KB Output is correct
14 Correct 16 ms 760 KB Output is correct
15 Correct 15 ms 804 KB Output is correct
16 Correct 22 ms 888 KB Output is correct
17 Correct 20 ms 836 KB Output is correct
18 Correct 20 ms 888 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 759 ms 2684 KB Output is correct
2 Correct 784 ms 2684 KB Output is correct
3 Correct 621 ms 2676 KB Output is correct
4 Correct 551 ms 2808 KB Output is correct
5 Correct 189 ms 1676 KB Output is correct
6 Correct 512 ms 2600 KB Output is correct
7 Correct 146 ms 1784 KB Output is correct
8 Correct 249 ms 2116 KB Output is correct
9 Correct 539 ms 2808 KB Output is correct
10 Correct 543 ms 2680 KB Output is correct
11 Correct 28 ms 888 KB Output is correct
12 Correct 315 ms 2168 KB Output is correct
13 Correct 273 ms 1912 KB Output is correct
14 Correct 272 ms 1912 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 759 ms 2684 KB Output is correct
2 Correct 784 ms 2684 KB Output is correct
3 Correct 621 ms 2676 KB Output is correct
4 Correct 551 ms 2808 KB Output is correct
5 Correct 189 ms 1676 KB Output is correct
6 Correct 512 ms 2600 KB Output is correct
7 Correct 146 ms 1784 KB Output is correct
8 Correct 249 ms 2116 KB Output is correct
9 Correct 539 ms 2808 KB Output is correct
10 Correct 543 ms 2680 KB Output is correct
11 Correct 28 ms 888 KB Output is correct
12 Correct 315 ms 2168 KB Output is correct
13 Correct 273 ms 1912 KB Output is correct
14 Correct 272 ms 1912 KB Output is correct
15 Correct 605 ms 2612 KB Output is correct
16 Correct 483 ms 2580 KB Output is correct
17 Correct 589 ms 2796 KB Output is correct
18 Correct 572 ms 2768 KB Output is correct
19 Correct 555 ms 2808 KB Output is correct
20 Correct 573 ms 2808 KB Output is correct
21 Correct 564 ms 2808 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 380 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 3 ms 504 KB Output is correct
11 Correct 3 ms 504 KB Output is correct
12 Correct 3 ms 504 KB Output is correct
13 Correct 25 ms 888 KB Output is correct
14 Correct 16 ms 760 KB Output is correct
15 Correct 15 ms 804 KB Output is correct
16 Correct 22 ms 888 KB Output is correct
17 Correct 20 ms 836 KB Output is correct
18 Correct 20 ms 888 KB Output is correct
19 Correct 759 ms 2684 KB Output is correct
20 Correct 784 ms 2684 KB Output is correct
21 Correct 621 ms 2676 KB Output is correct
22 Correct 551 ms 2808 KB Output is correct
23 Correct 189 ms 1676 KB Output is correct
24 Correct 512 ms 2600 KB Output is correct
25 Correct 146 ms 1784 KB Output is correct
26 Correct 249 ms 2116 KB Output is correct
27 Correct 539 ms 2808 KB Output is correct
28 Correct 543 ms 2680 KB Output is correct
29 Correct 28 ms 888 KB Output is correct
30 Correct 315 ms 2168 KB Output is correct
31 Correct 273 ms 1912 KB Output is correct
32 Correct 272 ms 1912 KB Output is correct
33 Correct 605 ms 2612 KB Output is correct
34 Correct 483 ms 2580 KB Output is correct
35 Correct 589 ms 2796 KB Output is correct
36 Correct 572 ms 2768 KB Output is correct
37 Correct 555 ms 2808 KB Output is correct
38 Correct 573 ms 2808 KB Output is correct
39 Correct 564 ms 2808 KB Output is correct
40 Correct 793 ms 3460 KB Output is correct
41 Correct 102 ms 888 KB Output is correct
42 Correct 577 ms 3452 KB Output is correct
43 Correct 542 ms 3192 KB Output is correct
44 Correct 556 ms 3320 KB Output is correct
45 Correct 855 ms 6648 KB Output is correct
46 Correct 108 ms 1144 KB Output is correct
47 Correct 646 ms 6776 KB Output is correct
48 Correct 610 ms 4708 KB Output is correct
49 Correct 613 ms 5472 KB Output is correct