답안 #168977

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
168977 2019-12-17T10:42:09 Z kostia244 Lottery (CEOI18_lot) C++17
0 / 100
1032 ms 2672 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 <= n; 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 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Incorrect 3 ms 376 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Incorrect 3 ms 376 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1032 ms 2672 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1032 ms 2672 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Incorrect 3 ms 376 KB Output isn't correct
9 Halted 0 ms 0 KB -