답안 #1095541

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1095541 2024-10-02T14:16:31 Z cpptowin Lottery (CEOI18_lot) C++17
35 / 100
313 ms 4868 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++;
        // cout << i << ' ' << 1 << ' ' << now << "\n";
        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]]++;
            }
            // cout << u - l + 1 << ' ' << v - l + 1 << ' ' << now << "\n";
            u++;
            v++;
        }
    }
    fo(i, 0, q - 1) fo(j, 0, i - 1) fo(h, 1, n) res[h][pos[qq[i]]] += res[h][pos[qq[j]]];
    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);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 313 ms 4696 KB Output is correct
2 Correct 305 ms 4816 KB Output is correct
3 Correct 200 ms 4696 KB Output is correct
4 Correct 174 ms 4696 KB Output is correct
5 Correct 60 ms 2652 KB Output is correct
6 Correct 162 ms 4440 KB Output is correct
7 Correct 57 ms 2648 KB Output is correct
8 Correct 96 ms 3420 KB Output is correct
9 Correct 169 ms 4764 KB Output is correct
10 Correct 170 ms 4700 KB Output is correct
11 Correct 8 ms 1364 KB Output is correct
12 Correct 94 ms 3596 KB Output is correct
13 Correct 78 ms 3416 KB Output is correct
14 Correct 75 ms 3164 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 313 ms 4696 KB Output is correct
2 Correct 305 ms 4816 KB Output is correct
3 Correct 200 ms 4696 KB Output is correct
4 Correct 174 ms 4696 KB Output is correct
5 Correct 60 ms 2652 KB Output is correct
6 Correct 162 ms 4440 KB Output is correct
7 Correct 57 ms 2648 KB Output is correct
8 Correct 96 ms 3420 KB Output is correct
9 Correct 169 ms 4764 KB Output is correct
10 Correct 170 ms 4700 KB Output is correct
11 Correct 8 ms 1364 KB Output is correct
12 Correct 94 ms 3596 KB Output is correct
13 Correct 78 ms 3416 KB Output is correct
14 Correct 75 ms 3164 KB Output is correct
15 Correct 182 ms 4692 KB Output is correct
16 Correct 150 ms 4488 KB Output is correct
17 Correct 182 ms 4700 KB Output is correct
18 Correct 172 ms 4868 KB Output is correct
19 Correct 173 ms 4864 KB Output is correct
20 Correct 176 ms 4700 KB Output is correct
21 Correct 172 ms 4696 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -