답안 #723562

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
723562 2023-04-14T05:08:49 Z penguin133 Lottery (CEOI18_lot) C++17
45 / 100
798 ms 49588 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 < vector <int> > pref;
vector <int> ft;
int n, k, q;
int32_t A[10005];
 
void solve(){
	cin >> n >> k;
	ft.resize(n+1);
	pref.resize(n-k+2);
	for(int i=0;i<n-k+2;i++)pref[i].resize(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:61:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   61 | main(){
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 25 ms 440 KB Output is correct
14 Correct 16 ms 2132 KB Output is correct
15 Correct 16 ms 2132 KB Output is correct
16 Correct 21 ms 1184 KB Output is correct
17 Correct 19 ms 1492 KB Output is correct
18 Correct 21 ms 1492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 798 ms 924 KB Output is correct
2 Correct 798 ms 928 KB Output is correct
3 Correct 574 ms 972 KB Output is correct
4 Correct 511 ms 4600 KB Output is correct
5 Runtime error 394 ms 49588 KB Memory limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 798 ms 924 KB Output is correct
2 Correct 798 ms 928 KB Output is correct
3 Correct 574 ms 972 KB Output is correct
4 Correct 511 ms 4600 KB Output is correct
5 Runtime error 394 ms 49588 KB Memory limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 25 ms 440 KB Output is correct
14 Correct 16 ms 2132 KB Output is correct
15 Correct 16 ms 2132 KB Output is correct
16 Correct 21 ms 1184 KB Output is correct
17 Correct 19 ms 1492 KB Output is correct
18 Correct 21 ms 1492 KB Output is correct
19 Correct 798 ms 924 KB Output is correct
20 Correct 798 ms 928 KB Output is correct
21 Correct 574 ms 972 KB Output is correct
22 Correct 511 ms 4600 KB Output is correct
23 Runtime error 394 ms 49588 KB Memory limit exceeded
24 Halted 0 ms 0 KB -