# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1012851 |
2024-07-02T17:22:07 Z |
pan |
Lottery (CEOI18_lot) |
C++17 |
|
342 ms |
20152 KB |
#include <bits/stdc++.h>
//#include "bits_stdc++.h"
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define endl '\n'
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define input(x) scanf("%lld", &x);
#define input2(x, y) scanf("%lld%lld", &x, &y);
#define input3(x, y, z) scanf("%lld%lld%lld", &x, &y, &z);
#define input4(x, y, z, a) scanf("%lld%lld%lld%lld", &x, &y, &z, &a);
#define print(x, y) printf("%lld%c", x, y);
#define show(x) cerr << #x << " is " << x << endl;
#define show2(x,y) cerr << #x << " is " << x << " " << #y << " is " << y << endl;
#define show3(x,y,z) cerr << #x << " is " << x << " " << #y << " is " << y << " " << #z << " is " << z << endl;
#define all(x) x.begin(), x.end()
#define discretize(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define FOR(i, x, n) for (ll i =x; i<=n; ++i)
#define RFOR(i, x, n) for (ll i =x; i>=n; --i)
using namespace std;
mt19937_64 rnd(chrono::steady_clock::now().time_since_epoch().count());
//using namespace __gnu_pbds;
//#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
//#define ordered_multiset tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>
typedef long long ll;
typedef long double ld;
typedef pair<ld, ll> pd;
typedef pair<string, ll> psl;
typedef pair<ll, ll> pi;
typedef pair<pi, ll> pii;
typedef pair<pi, pi> piii;
ll a[10005], qq[105];
vector<ll> dis;
vector<vector<ll> >ans, ans2;
ll dp[10005];
int main()
{
ll n, l, q;
input2(n, l);
for (ll i=0; i<n; ++i) input(a[i]);
input(q);
for (ll i=0; i<q; ++i) {input(qq[i]); dis.pb(qq[i]);}
discretize(dis);
ans.assign(dis.size(), vector<ll> (n, 0)); ans2.assign(dis.size(), vector<ll> (n, 0));
vector<ll> countingsort;
for (ll x=0; x<2; ++x)
{
//show(x);
fill(dp, dp+n, 0);
vector<ll> now;
for (ll i=0; i<l; ++i) for (ll j=1; j + i < n; ++j) dp[j] += (a[i]!=a[i+j]);
countingsort.assign(l+1, 0);
for (ll j=1; j<=n-l; ++j) countingsort[dp[j]]++;
for (ll j=1; j<=l; ++j) countingsort[j] += countingsort[j-1];
//sort(all(now));
for (ll j=0; j<dis.size(); ++j) ans[j][0] += countingsort[dis[j]];
for (ll i=1; i<=n-l; ++i)
{
now.clear();
for (ll j=1; j + (i-1) < n; ++j) dp[j] -= (a[i-1]!=a[i-1+j]);
for (ll j=1; j +( i+l-1) < n; ++j) dp[j] += (a[i+l-1]!=a[i+l-1+j]);
countingsort.assign(l+1, 0);
for (ll j=1; j<=n-l-i; ++j) countingsort[dp[j]]++;
for (ll j=1; j<=l; ++j) countingsort[j] += countingsort[j-1];
for (ll j=0; j<dis.size(); ++j) ans[j][i] += countingsort[dis[j]];
}
//for (ll i=0; i<dis.size(); ++i) for (ll j=0; j<=n-l; ++j) show(ans[i][j]);
reverse(a, a+n);
swap(ans, ans2);
}
//show(1);
//for (ll i=0; i<dis.size(); ++i) for (ll j=0; j<=n-l; ++j) show(ans[i][j]);
//for (ll i=0; i<dis.size(); ++i) for (ll j=0; j<=n-l; ++j) show(ans2[i][j]);
for (ll i=0; i<dis.size(); ++i) for (ll j=0; j<=n-l; ++j){ ans[i][j] += ans2[i][n - (j+l-1) - 1]; }
for (ll i=0; i<q; ++i)
{
ll j = lb(all(dis), qq[i])-dis.begin();
for (ll k=0; k<n-l+1; ++k) print(ans[j][k], ' ');
printf("\n");
}
//for (ll j=0; j<dis.size(); ++j) for (ll i=0; i<=n-l; ++i) show3(j, i, ans[j][i]);
return 0;
}
Compilation message
lot.cpp: In function 'int main()':
lot.cpp:61:17: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
61 | for (ll j=0; j<dis.size(); ++j) ans[j][0] += countingsort[dis[j]];
| ~^~~~~~~~~~~
lot.cpp:70:18: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
70 | for (ll j=0; j<dis.size(); ++j) ans[j][i] += countingsort[dis[j]];
| ~^~~~~~~~~~~
lot.cpp:79:16: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
79 | for (ll i=0; i<dis.size(); ++i) for (ll j=0; j<=n-l; ++j){ ans[i][j] += ans2[i][n - (j+l-1) - 1]; }
| ~^~~~~~~~~~~
lot.cpp:13:27: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
13 | #define input2(x, y) scanf("%lld%lld", &x, &y);
| ~~~~~^~~~~~~~~~~~~~~~~~~~
lot.cpp:44:2: note: in expansion of macro 'input2'
44 | input2(n, l);
| ^~~~~~
lot.cpp:12:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
12 | #define input(x) scanf("%lld", &x);
| ~~~~~^~~~~~~~~~~~
lot.cpp:45:25: note: in expansion of macro 'input'
45 | for (ll i=0; i<n; ++i) input(a[i]);
| ^~~~~
lot.cpp:12:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
12 | #define input(x) scanf("%lld", &x);
| ~~~~~^~~~~~~~~~~~
lot.cpp:46:2: note: in expansion of macro 'input'
46 | input(q);
| ^~~~~
lot.cpp:12:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
12 | #define input(x) scanf("%lld", &x);
| ~~~~~^~~~~~~~~~~~
lot.cpp:47:26: note: in expansion of macro 'input'
47 | for (ll i=0; i<q; ++i) {input(qq[i]); dis.pb(qq[i]);}
| ^~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
10 ms |
600 KB |
Output is correct |
14 |
Correct |
9 ms |
1116 KB |
Output is correct |
15 |
Correct |
8 ms |
872 KB |
Output is correct |
16 |
Correct |
13 ms |
1116 KB |
Output is correct |
17 |
Correct |
10 ms |
1116 KB |
Output is correct |
18 |
Correct |
10 ms |
1116 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
218 ms |
848 KB |
Output is correct |
2 |
Correct |
220 ms |
808 KB |
Output is correct |
3 |
Correct |
271 ms |
604 KB |
Output is correct |
4 |
Correct |
237 ms |
604 KB |
Output is correct |
5 |
Correct |
215 ms |
852 KB |
Output is correct |
6 |
Correct |
226 ms |
808 KB |
Output is correct |
7 |
Correct |
171 ms |
816 KB |
Output is correct |
8 |
Correct |
210 ms |
604 KB |
Output is correct |
9 |
Correct |
262 ms |
820 KB |
Output is correct |
10 |
Correct |
259 ms |
820 KB |
Output is correct |
11 |
Correct |
18 ms |
348 KB |
Output is correct |
12 |
Correct |
168 ms |
780 KB |
Output is correct |
13 |
Correct |
204 ms |
808 KB |
Output is correct |
14 |
Correct |
193 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
218 ms |
848 KB |
Output is correct |
2 |
Correct |
220 ms |
808 KB |
Output is correct |
3 |
Correct |
271 ms |
604 KB |
Output is correct |
4 |
Correct |
237 ms |
604 KB |
Output is correct |
5 |
Correct |
215 ms |
852 KB |
Output is correct |
6 |
Correct |
226 ms |
808 KB |
Output is correct |
7 |
Correct |
171 ms |
816 KB |
Output is correct |
8 |
Correct |
210 ms |
604 KB |
Output is correct |
9 |
Correct |
262 ms |
820 KB |
Output is correct |
10 |
Correct |
259 ms |
820 KB |
Output is correct |
11 |
Correct |
18 ms |
348 KB |
Output is correct |
12 |
Correct |
168 ms |
780 KB |
Output is correct |
13 |
Correct |
204 ms |
808 KB |
Output is correct |
14 |
Correct |
193 ms |
604 KB |
Output is correct |
15 |
Correct |
221 ms |
848 KB |
Output is correct |
16 |
Correct |
285 ms |
824 KB |
Output is correct |
17 |
Correct |
260 ms |
604 KB |
Output is correct |
18 |
Correct |
218 ms |
600 KB |
Output is correct |
19 |
Correct |
215 ms |
808 KB |
Output is correct |
20 |
Correct |
243 ms |
600 KB |
Output is correct |
21 |
Correct |
221 ms |
600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
10 ms |
600 KB |
Output is correct |
14 |
Correct |
9 ms |
1116 KB |
Output is correct |
15 |
Correct |
8 ms |
872 KB |
Output is correct |
16 |
Correct |
13 ms |
1116 KB |
Output is correct |
17 |
Correct |
10 ms |
1116 KB |
Output is correct |
18 |
Correct |
10 ms |
1116 KB |
Output is correct |
19 |
Correct |
218 ms |
848 KB |
Output is correct |
20 |
Correct |
220 ms |
808 KB |
Output is correct |
21 |
Correct |
271 ms |
604 KB |
Output is correct |
22 |
Correct |
237 ms |
604 KB |
Output is correct |
23 |
Correct |
215 ms |
852 KB |
Output is correct |
24 |
Correct |
226 ms |
808 KB |
Output is correct |
25 |
Correct |
171 ms |
816 KB |
Output is correct |
26 |
Correct |
210 ms |
604 KB |
Output is correct |
27 |
Correct |
262 ms |
820 KB |
Output is correct |
28 |
Correct |
259 ms |
820 KB |
Output is correct |
29 |
Correct |
18 ms |
348 KB |
Output is correct |
30 |
Correct |
168 ms |
780 KB |
Output is correct |
31 |
Correct |
204 ms |
808 KB |
Output is correct |
32 |
Correct |
193 ms |
604 KB |
Output is correct |
33 |
Correct |
221 ms |
848 KB |
Output is correct |
34 |
Correct |
285 ms |
824 KB |
Output is correct |
35 |
Correct |
260 ms |
604 KB |
Output is correct |
36 |
Correct |
218 ms |
600 KB |
Output is correct |
37 |
Correct |
215 ms |
808 KB |
Output is correct |
38 |
Correct |
243 ms |
600 KB |
Output is correct |
39 |
Correct |
221 ms |
600 KB |
Output is correct |
40 |
Correct |
215 ms |
4432 KB |
Output is correct |
41 |
Correct |
85 ms |
3792 KB |
Output is correct |
42 |
Correct |
261 ms |
4548 KB |
Output is correct |
43 |
Correct |
237 ms |
4180 KB |
Output is correct |
44 |
Correct |
237 ms |
4104 KB |
Output is correct |
45 |
Correct |
282 ms |
20152 KB |
Output is correct |
46 |
Correct |
100 ms |
16468 KB |
Output is correct |
47 |
Correct |
342 ms |
20152 KB |
Output is correct |
48 |
Correct |
285 ms |
16484 KB |
Output is correct |
49 |
Correct |
262 ms |
16992 KB |
Output is correct |