답안 #116168

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
116168 2019-06-11T04:14:07 Z JohnTitor Lottery (CEOI18_lot) C++11
0 / 100
3000 ms 504 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][101];
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][to[sum]]++;
//            ans[i+d][to[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, q) 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][r[k[i].second]]), putchar(" \n"[j==n]);
    FOR(i, l, n) write(ans[i]), putchar(" \n"[i==n]);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 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 5 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 261 ms 476 KB Output is correct
2 Correct 323 ms 456 KB Output is correct
3 Correct 185 ms 384 KB Output is correct
4 Execution timed out 3036 ms 504 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 261 ms 476 KB Output is correct
2 Correct 323 ms 456 KB Output is correct
3 Correct 185 ms 384 KB Output is correct
4 Execution timed out 3036 ms 504 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 2 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -