Submission #267445

# Submission time Handle Problem Language Result Execution time Memory
267445 2020-08-16T04:27:58 Z blue Street Lamps (APIO19_street_lamps) C++11
40 / 100
1319 ms 5300 KB
#include <iostream>
#include <vector>
using namespace std;

int main()
{
    int n, q;
    cin >> n >> q;

    if(n*n*q <= 2000000)
    {
        string S;
        cin >> S;

        bool on[n+1];
        for(int i = 1; i <= n; i++) on[i] = S[i-1] == '1';

        int drive[n+1][n+2];
        for(int a = 1; a <= n; a++) for(int b = a; b <= n+1; b++) drive[a][b] = 0;


        int A, B;

        for(int i = 1; i <= q; i++)
        {
            for(int a = 1; a <= n; a++)
            {
                for(int b = a+1; b <= n+1; b++)
                {
                    if(!on[b-1]) break;
                    drive[a][b]++;
                }
            }

            cin >> S;
            if(S == "toggle")
            {
                cin >> A;
                on[A] = !on[A];
            }
            else
            {
                cin >> A >> B;
                cout << drive[A][B] << '\n';
            }
        }
        return 0;
    }

    string S;
    cin >> S;

    vector<int> started(n+1, -1);
    vector<int> res(n+1, 0);
    for(int i = 1; i <= n; i++)
    {
        if(S[i-1] == '1') started[i] = 0;
    }


    int A, B;
    for(int i = 1; i <= q; i++)
    {
        cin >> S;
        if(S == "toggle")
        {
            cin >> A;
            if(started[A] == -1) started[A] = i;
            else
            {
                res[A] += i - started[A];
                started[A] = -1;
            }
        }
        else
        {
            cin >> A >> B;
            cout << res[A] + (started[A] != -1 ? i - started[A] : 0) << '\n';
        }
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 416 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 809 ms 1272 KB Output is correct
2 Correct 677 ms 1400 KB Output is correct
3 Correct 787 ms 1360 KB Output is correct
4 Correct 878 ms 3860 KB Output is correct
5 Correct 885 ms 4244 KB Output is correct
6 Correct 702 ms 3732 KB Output is correct
7 Correct 1319 ms 3836 KB Output is correct
8 Correct 1263 ms 5300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 256 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 416 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 809 ms 1272 KB Output is correct
9 Correct 677 ms 1400 KB Output is correct
10 Correct 787 ms 1360 KB Output is correct
11 Correct 878 ms 3860 KB Output is correct
12 Correct 885 ms 4244 KB Output is correct
13 Correct 702 ms 3732 KB Output is correct
14 Correct 1319 ms 3836 KB Output is correct
15 Correct 1263 ms 5300 KB Output is correct
16 Incorrect 1 ms 256 KB Output isn't correct
17 Halted 0 ms 0 KB -