Submission #971873

# Submission time Handle Problem Language Result Execution time Memory
971873 2024-04-29T12:21:45 Z vivkostov Street Lamps (APIO19_street_lamps) C++14
40 / 100
88 ms 23956 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
    {
        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")
            {
                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
            {
                cin>>r[i];
                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 13400 KB Output is correct
2 Correct 3 ms 13404 KB Output is correct
3 Correct 3 ms 13512 KB Output is correct
4 Correct 3 ms 13404 KB Output is correct
5 Correct 3 ms 13404 KB Output is correct
6 Correct 3 ms 13404 KB Output is correct
7 Correct 3 ms 13404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 61 ms 17424 KB Output is correct
2 Correct 69 ms 17748 KB Output is correct
3 Correct 64 ms 18256 KB Output is correct
4 Correct 67 ms 21732 KB Output is correct
5 Correct 75 ms 22248 KB Output is correct
6 Correct 63 ms 21736 KB Output is correct
7 Correct 80 ms 20424 KB Output is correct
8 Correct 88 ms 23956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 15460 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 15452 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 13400 KB Output is correct
2 Correct 3 ms 13404 KB Output is correct
3 Correct 3 ms 13512 KB Output is correct
4 Correct 3 ms 13404 KB Output is correct
5 Correct 3 ms 13404 KB Output is correct
6 Correct 3 ms 13404 KB Output is correct
7 Correct 3 ms 13404 KB Output is correct
8 Correct 61 ms 17424 KB Output is correct
9 Correct 69 ms 17748 KB Output is correct
10 Correct 64 ms 18256 KB Output is correct
11 Correct 67 ms 21732 KB Output is correct
12 Correct 75 ms 22248 KB Output is correct
13 Correct 63 ms 21736 KB Output is correct
14 Correct 80 ms 20424 KB Output is correct
15 Correct 88 ms 23956 KB Output is correct
16 Incorrect 3 ms 15460 KB Output isn't correct
17 Halted 0 ms 0 KB -