Submission #144186

# Submission time Handle Problem Language Result Execution time Memory
144186 2019-08-16T09:43:14 Z SamAnd Segway (COI19_segway) C++17
100 / 100
228 ms 13436 KB
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
const int N = 20004, M = 305;
struct ban
{
    int x, y, z;
};
struct ban1
{
    int i, x, q;
    ban1(){}
    ban1(int i, int x, int q)
    {
        this->i = i;
        this->x = x;
        this->q = q;
    }
};

int n;
ban a[N];

int m;
bool c[M];

queue<ban1> q[M * 50];

int t[M];
void ubd(int x, int y)
{
    ++x;
    while (x < M)
    {
        t[x] += y;
        x += (x & (-x));
    }
}
int qry(int l, int r)
{
    int ans = 0;
    ++r;
    while (r > 0)
    {
        ans += t[r];
        r -= (r & (-r));
    }
    while (l > 0)
    {
        ans -= t[l];
        l -= (l & (-l));
    }
    return ans;
}

int qq[M];

int ans[N];
int main()
{
    //freopen("input.txt", "r", stdin);
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i)
    {
        scanf("%d%d%d", &a[i].x, &a[i].y, &a[i].z);
    }
    scanf("%d", &m);
    for (int i = 0; i < m; ++i)
    {
        int x;
        scanf("%d", &x);
        c[x] = true;
    }
    for (int i = 1; i <= n; ++i)
    {
        q[0].push(ban1(i, 0, 0));
        ubd(0, 1);
    }
    for (int i = 0; i < M * 50; ++i)
    {
        memset(qq, 0, sizeof qq);
        while (!q[i].empty())
        {
            ban1 t = q[i].front();
            q[i].pop();
            if (t.x == 300)
            {
                ans[t.i] = i;
                continue;
            }
            ubd(t.x, -1);
            if (!t.q && c[t.x])
            {
                t.q = ((qry(t.x + 1, 300) - qq[t.x]) % 20);
            }
            int d;
            if (t.q)
            {
                d = i + 1;
            }
            else
            {
                if (t.x >= 200)
                    d = i + a[t.i].z;
                else if (t.x >= 100)
                    d = i + a[t.i].y;
                else
                    d = i + a[t.i].x;
            }
            qq[t.x]++;
            if (t.q)
            {
                --t.q;
                ++t.x;
            }
            else
            {
                ++t.x;
            }
            q[d].push(t);
            ubd(t.x, 1);
        }
    }
    for (int i = 1; i <= n; ++i)
        printf("%d\n", ans[i]);
    return 0;
}

Compilation message

segway.cpp: In function 'int main()':
segway.cpp:62:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
segway.cpp:65:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d", &a[i].x, &a[i].y, &a[i].z);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
segway.cpp:67:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &m);
     ~~~~~^~~~~~~~~~
segway.cpp:71:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &x);
         ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 12 ms 10360 KB Output is correct
2 Correct 15 ms 10360 KB Output is correct
3 Correct 21 ms 10360 KB Output is correct
4 Correct 44 ms 10616 KB Output is correct
5 Correct 228 ms 13016 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 10360 KB Output is correct
2 Correct 12 ms 10360 KB Output is correct
3 Correct 12 ms 10360 KB Output is correct
4 Correct 12 ms 10360 KB Output is correct
5 Correct 12 ms 10360 KB Output is correct
6 Correct 13 ms 10364 KB Output is correct
7 Correct 13 ms 10360 KB Output is correct
8 Correct 14 ms 10360 KB Output is correct
9 Correct 15 ms 10360 KB Output is correct
10 Correct 16 ms 10360 KB Output is correct
11 Correct 15 ms 10360 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 10360 KB Output is correct
2 Correct 15 ms 10360 KB Output is correct
3 Correct 21 ms 10360 KB Output is correct
4 Correct 44 ms 10616 KB Output is correct
5 Correct 228 ms 13016 KB Output is correct
6 Correct 12 ms 10360 KB Output is correct
7 Correct 12 ms 10360 KB Output is correct
8 Correct 12 ms 10360 KB Output is correct
9 Correct 12 ms 10360 KB Output is correct
10 Correct 12 ms 10360 KB Output is correct
11 Correct 13 ms 10364 KB Output is correct
12 Correct 13 ms 10360 KB Output is correct
13 Correct 14 ms 10360 KB Output is correct
14 Correct 15 ms 10360 KB Output is correct
15 Correct 16 ms 10360 KB Output is correct
16 Correct 15 ms 10360 KB Output is correct
17 Correct 24 ms 10488 KB Output is correct
18 Correct 31 ms 10616 KB Output is correct
19 Correct 95 ms 11516 KB Output is correct
20 Correct 126 ms 12076 KB Output is correct
21 Correct 153 ms 12408 KB Output is correct
22 Correct 193 ms 13236 KB Output is correct
23 Correct 162 ms 13436 KB Output is correct