답안 #733648

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
733648 2023-05-01T06:42:10 Z penguin133 Lottery (CEOI18_lot) C++17
0 / 100
640 ms 468 KB
#include <bits/stdc++.h>
using namespace std;
 
#define int short
#define pi pair<int, int>
#define pii pair<int, pi>
#define fi first
#define se second
#ifdef _WIN32
#define getchar_unlocked _getchar_nolock
#endif
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
 

vector <int> ft;
int n, k, q;
int32_t A[10005];
 
void solve(){
	cin >> n >> k;
	ft.resize(n+1);
	int pref[n-k+2][k+1];
	for(int i=1;i<=n;i++){
		cin >> A[i];
	}
	for(int i=1;i<=n;i++){
		for(auto &j : ft)j = 0;
		for(int j=1;j<=n-i;j++){
			if(A[j] != A[i+j])continue;
			int a = j, b = i + j;
			int lb = 1 + max(0, b - (n - k + 1));
			int ub = min(a, k);
			
			//cerr << i << ' ' << j[a] << ' ' << j[b] << ' ' << j[b] - j[a] << ' ' << lb << ' ' << ub << ' ' << ft[j[b]-j[a]].size() << '\n';
			if(lb > ub)continue;
			ft[a-ub+1]++;
			ft[a-lb+2]--;
		}
		for(int j=1;j<=n-k-i+1;j++){
			ft[j] += ft[j-1];
			//cout << ft[j] << ' ';
			pref[j][k-ft[j]]++;
			pref[j+i][k-ft[j]]++;
		}
		//cout << '\n';
	}
	for(int i=1;i<n-k+2;i++){
		for(int j=1;j<=k;j++)pref[i][j] += pref[i][j-1];
		//for(int j=0;j<=k;j++)cerr << pref[i][j] << ' ';
		//cerr << '\n';
	}
	cin >> q;
	while(q--){
		int x; cin >> x;
		for(int i=1;i<=n-k+1;i++)cout << pref[i][x] << ' ';
		cout << '\n';
	}
}
 
main(){
	ios::sync_with_stdio(0);cin.tie(0);
	int tc = 1;
	//cin >> tc;
	for(int tc1=1;tc1<=tc;tc1++){
		// cout << "Case #" << tc1 << ": ";
		solve();
	}
}

Compilation message

lot.cpp:60:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   60 | main(){
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 328 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 328 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 640 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 640 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 328 KB Output isn't correct
3 Halted 0 ms 0 KB -