답안 #723542

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
723542 2023-04-14T04:49:35 Z penguin133 Lottery (CEOI18_lot) C++17
45 / 100
31 ms 65536 KB
#include <bits/stdc++.h>
using namespace std;

//#define int long long
#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> > ft, pref;
int n, k, q;
vector < vector <int> > mp;
int A[10005];

void solve(){
	cin >> n >> k;
	ft.resize(n-k+2);
	pref.resize(n-k+2);
	for(int i=0;i<n-k+2;i++)ft[i].resize(n-k-i+3), pref[i].resize(k+1);
	for(int i=1;i<=n;i++){
		cin >> A[i];
	}
	for(int i=1;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			if(A[i] != A[j])continue;
			int lb = 1 + max(0, j - (n - k + 1));
			int ub = min(i, 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[j-i][i-ub+1]++;
			ft[j-i][i-lb+2]--;
		}
	}
	int idx = 0;
	for(auto i : ft){
		if(idx == 0){
			idx++;
			continue;
		}
		for(int j=1;j<=n-k-idx+1;j++)i[j] += i[j-1];
		//for(int j=0;j<(int)i.size();j++)cerr << i[j] << ' ';
		//cerr << '\n';
		for(int j=1;j<=n-k-idx+1;j++)pref[j][k-i[j]]++, pref[j+idx][k-i[j]]++;
		idx++;
	}
	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:64:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   64 | main(){
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 328 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 328 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 2 ms 456 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
11 Correct 2 ms 588 KB Output is correct
12 Correct 2 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 328 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 328 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 2 ms 456 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
11 Correct 2 ms 588 KB Output is correct
12 Correct 2 ms 468 KB Output is correct
13 Correct 31 ms 8352 KB Output is correct
14 Correct 19 ms 7456 KB Output is correct
15 Correct 18 ms 7504 KB Output is correct
16 Correct 27 ms 8264 KB Output is correct
17 Correct 24 ms 8120 KB Output is correct
18 Correct 26 ms 8116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 31 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 31 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 328 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 328 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 2 ms 456 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 2 ms 468 KB Output is correct
11 Correct 2 ms 588 KB Output is correct
12 Correct 2 ms 468 KB Output is correct
13 Correct 31 ms 8352 KB Output is correct
14 Correct 19 ms 7456 KB Output is correct
15 Correct 18 ms 7504 KB Output is correct
16 Correct 27 ms 8264 KB Output is correct
17 Correct 24 ms 8120 KB Output is correct
18 Correct 26 ms 8116 KB Output is correct
19 Runtime error 31 ms 65536 KB Execution killed with signal 9
20 Halted 0 ms 0 KB -