Submission #971875

# Submission time Handle Problem Language Result Execution time Memory
971875 2024-04-29T12:24:04 Z vivkostov Street Lamps (APIO19_street_lamps) C++14
40 / 100
87 ms 18152 KB
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
void speed()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    /*#ifdef ONLINE_JUDGE
    freopen("taxi.in", "r", stdin);
    freopen("taxi.out", "w", stdout);
    #endif
    */
}
int n,q;
string s[305];
string a[300005];
int l[300005],r[300005],safe[300005],last[300005],state[300005];
int answer(int l,int r,int ti)
{
    int br=0;
    for(int i=0; i<ti; i++)
    {
        for(int j=l; j<r; j++)
        {
            if(s[i][j]=='0')break;
            if(j==r-1)br++;
        }
    }
    return br;
}
void read()
{
    cin>>n>>q>>s[0];
    if(n<=100&&q<=100)
    {
        for(int i=1; i<=q; i++)
        {
            cin>>a[i]>>l[i];
            l[i]--;
            s[i]=s[i-1];
            if(a[i]=="query")
            {
                cin>>r[i];
                r[i]--;
                cout<<answer(l[i],r[i],i)<<endl;
            }
            else
            {
                s[i][l[i]]++;
                if(s[i][l[i]]=='2')s[i][l[i]]='0';
            }
        }
    }
    else
    {
        int h=0;
        for(int i=0; i<n; i++)
        {
            if(s[0][i]=='1')state[i]=1;
        }
        for(int i=1; i<=q; i++)
        {
            cin>>a[i]>>l[i];
            l[i]--;
            if(a[i]=="toggle");
            else
            {
                cin>>r[i];
                if(r[i]-l[i]!=2)h=1;
            }
        }
        if(!h)
        {
            for(int i=1; i<=q; i++)
            {
                if(a[i]=="toggle")
                {
                    if(state[l[i]]==1)safe[l[i]]+=i-last[l[i]];
                    last[l[i]]=i;
                    state[l[i]]=(state[l[i]]+1)%2;
                }
                else
                {
                    cout<<safe[l[i]]+(i-last[l[i]])*state[l[i]]<<endl;
                }
            }
        }
    }
}
int main()
{
    speed();
    read();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 13404 KB Output is correct
2 Correct 2 ms 13404 KB Output is correct
3 Correct 2 ms 13512 KB Output is correct
4 Correct 2 ms 13404 KB Output is correct
5 Correct 2 ms 13404 KB Output is correct
6 Correct 4 ms 14168 KB Output is correct
7 Correct 3 ms 13404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 58 ms 14420 KB Output is correct
2 Correct 61 ms 14320 KB Output is correct
3 Correct 60 ms 14416 KB Output is correct
4 Correct 70 ms 16648 KB Output is correct
5 Correct 70 ms 17124 KB Output is correct
6 Correct 63 ms 16612 KB Output is correct
7 Correct 76 ms 14560 KB Output is correct
8 Correct 87 ms 18152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 13404 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 13404 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 13404 KB Output is correct
2 Correct 2 ms 13404 KB Output is correct
3 Correct 2 ms 13512 KB Output is correct
4 Correct 2 ms 13404 KB Output is correct
5 Correct 2 ms 13404 KB Output is correct
6 Correct 4 ms 14168 KB Output is correct
7 Correct 3 ms 13404 KB Output is correct
8 Correct 58 ms 14420 KB Output is correct
9 Correct 61 ms 14320 KB Output is correct
10 Correct 60 ms 14416 KB Output is correct
11 Correct 70 ms 16648 KB Output is correct
12 Correct 70 ms 17124 KB Output is correct
13 Correct 63 ms 16612 KB Output is correct
14 Correct 76 ms 14560 KB Output is correct
15 Correct 87 ms 18152 KB Output is correct
16 Incorrect 3 ms 13404 KB Output isn't correct
17 Halted 0 ms 0 KB -