Submission #1127085

#TimeUsernameProblemLanguageResultExecution timeMemory
1127085TrieTrLottery (CEOI18_lot)C++20
45 / 100
3094 ms4636 KiB
#include<bits/stdc++.h>
using namespace std;

void local() {
    #define taskname ""
    if (fopen(taskname".inp", "r")) {
        freopen(taskname".inp", "r", stdin);
        freopen(taskname".out", "w", stdout);
    }
}

#define ll long long
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

template<class X, class Y> bool mini(X &a, const Y &b) {return (a > b) ? a = b, true : false;}
template<class X, class Y> bool maxi(X &a, const Y &b) {return (a < b) ? a = b, true : false;}

const int N = 1e4 + 5;
const int Q = 1e2 + 5;

int n, l, q, a[N], que[N];
int cnt[N], pf[N];
int ans[N][Q];

int main() {
    fastio; local();
    cin >> n >> l;
    for(int i = 1; i <= n; i++) cin >> a[i];
    cin >> q;
    for(int i = 1; i <= q; i++) cin >> que[i];
    for(int i = 1; i + l - 1 <= n; i++) {
    	memset(cnt, 0, sizeof(cnt));
    	memset(pf, 0, sizeof(pf));
    	for(int p = 0; p < l; p++)
    		for(int j = 1; j + l - 1 <= n; j++) cnt[j] += (a[i + p] != a[j + p]);
    	for(int j = 1; j + l - 1 <= n; j++) pf[cnt[j]]++;
    	for(int j = 1; j <= l; j++) pf[j] += pf[j - 1];
    	for(int j = 1; j <= q; j++) ans[i][j] = pf[que[j]] - 1;
    }
	for(int i = 1; i <= q; i++)
		for(int j = 1; j + l - 1 <= n; j++) cout << ans[j][i] << " \n"[j == n - l + 1];
}

Compilation message (stderr)

lot.cpp: In function 'void local()':
lot.cpp:7:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |         freopen(taskname".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
lot.cpp:8:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |         freopen(taskname".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...