Submission #144175

# Submission time Handle Problem Language Result Execution time Memory
144175 2019-08-16T09:26:50 Z SamAnd Segway (COI19_segway) C++17
0 / 100
25 ms 10392 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 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)
    {
        queue<int> 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, M - 1) % 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;
            }
            if (t.q)
            {
                --t.q;
                ++t.x;
            }
            else
            {
                ++t.x;
            }
            q[d].push(t);
            qq.push(t.x);
        }
        while (!qq.empty())
        {
            ubd(qq.front(), 1);
            qq.pop();
        }
    }
    for (int i = 1; i <= n; ++i)
        printf("%d\n", ans[i]);
    return 0;
}

Compilation message

segway.cpp: In function 'int main()':
segway.cpp:60:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
segway.cpp:63: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:65:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &m);
     ~~~~~^~~~~~~~~~
segway.cpp:69: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 14 ms 10360 KB Output is correct
2 Correct 16 ms 10360 KB Output is correct
3 Incorrect 25 ms 10360 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 10392 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14 ms 10360 KB Output is correct
2 Correct 16 ms 10360 KB Output is correct
3 Incorrect 25 ms 10360 KB Output isn't correct
4 Halted 0 ms 0 KB -