Submission #1095544

# Submission time Handle Problem Language Result Execution time Memory
1095544 2024-10-02T14:27:14 Z cpptowin Lottery (CEOI18_lot) C++17
35 / 100
297 ms 5060 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];
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;
    }
    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) res[h][pos[qq[i]]] += res[h][pos[qq[i - 1]]];
    fo(j, 1, q)
    {
        fo(i, 1, n - l + 1) cout << res[i][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 600 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 464 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Incorrect 0 ms 344 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 464 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Incorrect 0 ms 344 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 296 ms 4808 KB Output is correct
2 Correct 297 ms 4808 KB Output is correct
3 Correct 179 ms 4696 KB Output is correct
4 Correct 176 ms 5060 KB Output is correct
5 Correct 60 ms 2652 KB Output is correct
6 Correct 157 ms 4608 KB Output is correct
7 Correct 58 ms 2780 KB Output is correct
8 Correct 98 ms 3420 KB Output is correct
9 Correct 169 ms 4752 KB Output is correct
10 Correct 172 ms 4828 KB Output is correct
11 Correct 8 ms 1368 KB Output is correct
12 Correct 93 ms 3596 KB Output is correct
13 Correct 82 ms 3408 KB Output is correct
14 Correct 77 ms 3164 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 296 ms 4808 KB Output is correct
2 Correct 297 ms 4808 KB Output is correct
3 Correct 179 ms 4696 KB Output is correct
4 Correct 176 ms 5060 KB Output is correct
5 Correct 60 ms 2652 KB Output is correct
6 Correct 157 ms 4608 KB Output is correct
7 Correct 58 ms 2780 KB Output is correct
8 Correct 98 ms 3420 KB Output is correct
9 Correct 169 ms 4752 KB Output is correct
10 Correct 172 ms 4828 KB Output is correct
11 Correct 8 ms 1368 KB Output is correct
12 Correct 93 ms 3596 KB Output is correct
13 Correct 82 ms 3408 KB Output is correct
14 Correct 77 ms 3164 KB Output is correct
15 Correct 173 ms 4676 KB Output is correct
16 Correct 152 ms 4696 KB Output is correct
17 Correct 194 ms 4892 KB Output is correct
18 Correct 180 ms 4700 KB Output is correct
19 Correct 180 ms 4876 KB Output is correct
20 Correct 176 ms 4856 KB Output is correct
21 Correct 171 ms 4696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 464 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Incorrect 0 ms 344 KB Output isn't correct
7 Halted 0 ms 0 KB -