답안 #116172

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
116172 2019-06-11T04:19:37 Z JohnTitor Lottery (CEOI18_lot) C++11
25 / 100
540 ms 12408 KB
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for(int i=(j); i<=(k); i++)
#define FFOR(i, j, k) for(int i=(j); i<(k); i++)
#define DFOR(i, j, k) for(int i=(j); i>=(k); i--)
#define bug(x) cerr<<#x<<" = "<<(x)<<'\n'
#define pb push_back
#define mp make_pair
#define bit(s, i) (((s)>>(i))&1LL)
#define mask(i) ((1LL<<(i)))
#define builtin_popcount __builtin_popcountll
#define __builtin_popcount __builtin_popcountll
using ll=long long; using ld=long double;
mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); const ld pi=acos(0)*2;
template <typename T> inline void read(T &x){char c; bool nega=0; while((!isdigit(c=getchar()))&&(c!='-')); if(c=='-'){nega=1; c=getchar();} x=c-48; while(isdigit(c=getchar())) x=x*10+c-48; if(nega) x=-x;}
template <typename T> inline void writep(T x){if(x>9) writep(x/10); putchar(x%10+48);}
template <typename T> inline void write(T x){if(x<0){ putchar('-'); x=-x;} writep(x);}
template <typename T> inline void writeln(T x){write(x); putchar('\n');}
#define taskname "Lottery"
int n, l, q;
int a[10001];
int to[10001];
int ans[10001][303];
//int ans[10001];
int r[101];
pair <int, int> k[101];
int main(){
    #ifdef Aria
        if(fopen(taskname".in", "r"))
            freopen(taskname".in", "r", stdin);
    #endif // Aria
    read(n);
    read(l);
    FOR(i, 1, n) read(a[i]);
    read(q);
    FOR(i, 1, q){
        read(k[i].first);
        k[i].second=i;
    }
//    sort(k+1, k+q+1);
//    DFOR(i, q, 1){
//        r[k[i].second]=i;
//        FOR(j, 0, k[i].first) to[j]=i;
//    }
    FOR(d, 1, n){
        if(d+l>n) break;
        int sum=0;
        FFOR(i, 1, l) sum+=(a[i]!=a[i+d]);
        FOR(i, l, n){
            if(i+d>n) break;
            sum+=(a[i]!=a[i+d]);
//            int sum=0;
//            FFOR(j, 0, l) sum+=a[i-j]!=a[i+d-j];
            ans[i][sum]++;
            ans[i+d][sum]++;
//            if(sum==0) ans[i]++;
//            if(sum==0) ans[i+d]++;
            sum-=(a[i-l+1]!=a[i-l+1+d]);
        }
    }
    FOR(i, 1, n) FOR(j, 1, l) ans[i][j]+=ans[i][j-1];
//    sort(k+1, k+q+1, [](pair <int, int> A, pair <int, int> B){
//        return A.second<B.second;
//    });
    FOR(i, 1, q) FOR(j, l, n) write(ans[j][k[i].first]), putchar(" \n"[j==n]);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 512 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 512 KB Output is correct
7 Correct 2 ms 512 KB Output is correct
8 Correct 2 ms 768 KB Output is correct
9 Correct 2 ms 640 KB Output is correct
10 Correct 3 ms 640 KB Output is correct
11 Correct 2 ms 640 KB Output is correct
12 Correct 2 ms 768 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 512 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 512 KB Output is correct
7 Correct 2 ms 512 KB Output is correct
8 Correct 2 ms 768 KB Output is correct
9 Correct 2 ms 640 KB Output is correct
10 Correct 3 ms 640 KB Output is correct
11 Correct 2 ms 640 KB Output is correct
12 Correct 2 ms 768 KB Output is correct
13 Correct 13 ms 2688 KB Output is correct
14 Incorrect 16 ms 3048 KB Output isn't correct
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 534 ms 12288 KB Output is correct
2 Correct 526 ms 12288 KB Output is correct
3 Correct 540 ms 12408 KB Output is correct
4 Correct 515 ms 12408 KB Output is correct
5 Incorrect 236 ms 12408 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 534 ms 12288 KB Output is correct
2 Correct 526 ms 12288 KB Output is correct
3 Correct 540 ms 12408 KB Output is correct
4 Correct 515 ms 12408 KB Output is correct
5 Incorrect 236 ms 12408 KB Output isn't correct
6 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 512 KB Output is correct
4 Correct 2 ms 512 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 512 KB Output is correct
7 Correct 2 ms 512 KB Output is correct
8 Correct 2 ms 768 KB Output is correct
9 Correct 2 ms 640 KB Output is correct
10 Correct 3 ms 640 KB Output is correct
11 Correct 2 ms 640 KB Output is correct
12 Correct 2 ms 768 KB Output is correct
13 Correct 13 ms 2688 KB Output is correct
14 Incorrect 16 ms 3048 KB Output isn't correct
15 Halted 0 ms 0 KB -