# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1095546 |
2024-10-02T14:29:17 Z |
cpptowin |
Lottery (CEOI18_lot) |
C++17 |
|
398 ms |
8796 KB |
#include <bits/stdc++.h>
#define fo(i, d, c) for (int i = d; i <= c; i++)
#define fod(i, c, d) for (int i = c; i >= d; i--)
#define maxn 1000010
#define N 1010
#define fi first
#define se second
#define pb emplace_back
#define en cout << "\n";
#define bitcount(x) __builtin_popcountll(x)
#define pii pair<int, int>
#define vii vector<pii>
#define lb(x) x & -x
#define bit(i, j) ((i >> j) & 1)
#define offbit(i, j) (i ^ (1LL << j))
#define onbit(i, j) (i | (1LL << j))
#define vi vector<int>
#define all(x) x.begin(), x.end()
#define ss(x) (int)x.size()
template <typename T1, typename T2>
bool minimize(T1 &a, T2 b)
{
if (a > b)
{
a = b;
return true;
}
return false;
}
template <typename T1, typename T2>
bool maximize(T1 &a, T2 b)
{
if (a < b)
{
a = b;
return true;
}
return false;
}
using namespace std;
const int nsqrt = 450;
const int mod = 1e9 + 7;
void add(int &x, int k)
{
x += k;
x %= mod;
if (x < 0)
x += mod;
}
void del(int &x, int k)
{
x -= k;
x %= mod;
if (x < 0)
x += mod;
}
int n, l, q;
int res[10010][110], pos[10010],cc[111];
int a[maxn];
main()
{
#define name "TASK"
if (fopen(name ".inp", "r"))
{
freopen(name ".inp", "r", stdin);
freopen(name ".out", "w", stdout);
}
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> l;
fo(i, 1, n) cin >> a[i];
cin >> q;
vi qq;
fo(i, 1, q)
{
int x;
cin >> x;
qq.pb(x);
pos[x] = i;
cc[i] = x;
}
sort(all(qq));
fod(i, l, 0) if (!pos[i]) pos[i] = pos[i + 1];
fo(i, 1, n - l + 1)
{
int now = 0;
fo(j, 1, l) if (a[i + j - 1] != a[j]) now++;
if (i != 1)
{
res[i][pos[now]]++;
res[1][pos[now]]++;
}
int u = i + l, v = l + 1;
while (u <= n and v <= n)
{
if (a[u - l] != a[v - l])
now--;
if (a[u] != a[v])
now++;
if (u - l + 1 != v - l + 1)
{
res[u - l + 1][pos[now]]++;
res[v - l + 1][pos[now]]++;
}
u++;
v++;
}
}
fo(i, 1, q - 1) fo(h, 1, n - l + 1) if(qq[i] > qq[i - 1])
res[h][pos[qq[i]]] += res[h][pos[qq[i - 1]]];
fo(j, 1, q)
{
fo(i, 1, n - l + 1) cout << res[i][pos[cc[j]]] << ' ';
en;
}
}
Compilation message
lot.cpp:60:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
60 | main()
| ^~~~
lot.cpp: In function 'int main()':
lot.cpp:65:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
65 | freopen(name ".inp", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
lot.cpp:66:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
66 | freopen(name ".out", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 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 |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
604 KB |
Output is correct |
12 |
Correct |
1 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 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 |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
604 KB |
Output is correct |
12 |
Correct |
1 ms |
604 KB |
Output is correct |
13 |
Correct |
8 ms |
1372 KB |
Output is correct |
14 |
Correct |
5 ms |
1112 KB |
Output is correct |
15 |
Correct |
4 ms |
992 KB |
Output is correct |
16 |
Correct |
7 ms |
1372 KB |
Output is correct |
17 |
Correct |
6 ms |
1116 KB |
Output is correct |
18 |
Correct |
6 ms |
1112 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
322 ms |
4816 KB |
Output is correct |
2 |
Correct |
298 ms |
4696 KB |
Output is correct |
3 |
Correct |
190 ms |
4696 KB |
Output is correct |
4 |
Correct |
179 ms |
4812 KB |
Output is correct |
5 |
Correct |
58 ms |
2764 KB |
Output is correct |
6 |
Correct |
159 ms |
4404 KB |
Output is correct |
7 |
Correct |
56 ms |
2788 KB |
Output is correct |
8 |
Correct |
103 ms |
3664 KB |
Output is correct |
9 |
Correct |
170 ms |
4700 KB |
Output is correct |
10 |
Correct |
174 ms |
4696 KB |
Output is correct |
11 |
Correct |
8 ms |
1368 KB |
Output is correct |
12 |
Correct |
93 ms |
3600 KB |
Output is correct |
13 |
Correct |
75 ms |
3164 KB |
Output is correct |
14 |
Correct |
75 ms |
3160 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
322 ms |
4816 KB |
Output is correct |
2 |
Correct |
298 ms |
4696 KB |
Output is correct |
3 |
Correct |
190 ms |
4696 KB |
Output is correct |
4 |
Correct |
179 ms |
4812 KB |
Output is correct |
5 |
Correct |
58 ms |
2764 KB |
Output is correct |
6 |
Correct |
159 ms |
4404 KB |
Output is correct |
7 |
Correct |
56 ms |
2788 KB |
Output is correct |
8 |
Correct |
103 ms |
3664 KB |
Output is correct |
9 |
Correct |
170 ms |
4700 KB |
Output is correct |
10 |
Correct |
174 ms |
4696 KB |
Output is correct |
11 |
Correct |
8 ms |
1368 KB |
Output is correct |
12 |
Correct |
93 ms |
3600 KB |
Output is correct |
13 |
Correct |
75 ms |
3164 KB |
Output is correct |
14 |
Correct |
75 ms |
3160 KB |
Output is correct |
15 |
Correct |
187 ms |
4700 KB |
Output is correct |
16 |
Correct |
153 ms |
4476 KB |
Output is correct |
17 |
Correct |
203 ms |
4892 KB |
Output is correct |
18 |
Correct |
176 ms |
4696 KB |
Output is correct |
19 |
Correct |
182 ms |
4700 KB |
Output is correct |
20 |
Correct |
174 ms |
4860 KB |
Output is correct |
21 |
Correct |
195 ms |
4696 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 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 |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
604 KB |
Output is correct |
12 |
Correct |
1 ms |
604 KB |
Output is correct |
13 |
Correct |
8 ms |
1372 KB |
Output is correct |
14 |
Correct |
5 ms |
1112 KB |
Output is correct |
15 |
Correct |
4 ms |
992 KB |
Output is correct |
16 |
Correct |
7 ms |
1372 KB |
Output is correct |
17 |
Correct |
6 ms |
1116 KB |
Output is correct |
18 |
Correct |
6 ms |
1112 KB |
Output is correct |
19 |
Correct |
322 ms |
4816 KB |
Output is correct |
20 |
Correct |
298 ms |
4696 KB |
Output is correct |
21 |
Correct |
190 ms |
4696 KB |
Output is correct |
22 |
Correct |
179 ms |
4812 KB |
Output is correct |
23 |
Correct |
58 ms |
2764 KB |
Output is correct |
24 |
Correct |
159 ms |
4404 KB |
Output is correct |
25 |
Correct |
56 ms |
2788 KB |
Output is correct |
26 |
Correct |
103 ms |
3664 KB |
Output is correct |
27 |
Correct |
170 ms |
4700 KB |
Output is correct |
28 |
Correct |
174 ms |
4696 KB |
Output is correct |
29 |
Correct |
8 ms |
1368 KB |
Output is correct |
30 |
Correct |
93 ms |
3600 KB |
Output is correct |
31 |
Correct |
75 ms |
3164 KB |
Output is correct |
32 |
Correct |
75 ms |
3160 KB |
Output is correct |
33 |
Correct |
187 ms |
4700 KB |
Output is correct |
34 |
Correct |
153 ms |
4476 KB |
Output is correct |
35 |
Correct |
203 ms |
4892 KB |
Output is correct |
36 |
Correct |
176 ms |
4696 KB |
Output is correct |
37 |
Correct |
182 ms |
4700 KB |
Output is correct |
38 |
Correct |
174 ms |
4860 KB |
Output is correct |
39 |
Correct |
195 ms |
4696 KB |
Output is correct |
40 |
Correct |
337 ms |
5540 KB |
Output is correct |
41 |
Correct |
12 ms |
1116 KB |
Output is correct |
42 |
Correct |
201 ms |
5568 KB |
Output is correct |
43 |
Correct |
200 ms |
4968 KB |
Output is correct |
44 |
Correct |
195 ms |
5220 KB |
Output is correct |
45 |
Correct |
398 ms |
8380 KB |
Output is correct |
46 |
Correct |
27 ms |
1364 KB |
Output is correct |
47 |
Correct |
252 ms |
8796 KB |
Output is correct |
48 |
Correct |
226 ms |
6772 KB |
Output is correct |
49 |
Correct |
216 ms |
7268 KB |
Output is correct |