Submission #440449

# Submission time Handle Problem Language Result Execution time Memory
440449 2021-07-02T09:56:35 Z VladM Street Lamps (APIO19_street_lamps) C++14
20 / 100
821 ms 13348 KB
#include <bits/stdc++.h>

using namespace std;

long long n, q, nom, it, flag, a, b, res;

string s[107], r;

void solve1()
{
    cin>>s[0];
    s[0]='&'+s[0];
    nom=0;
    while(q--)
    {
        cin>>r;
        if(r[0]=='t')
        {
            cin>>it;
            nom++;
            s[nom]=s[nom-1];
            if(s[nom][it]=='0') s[nom][it]='1';
            else s[nom][it]='0';
            continue;
        }
        cin>>a>>b;
        res=0;
        for(int k=0; k<=nom; k++)
        {
            flag=0;
            for(int i=a; i<b; i++)
            {
                if(s[k][i]=='0')
                {
                    flag=1;
                    break;
                }
            }
            if(flag==0) res++;
        }
        nom++;
        s[nom]=s[nom-1];
        cout<<res<<endl;
    }
    return;
}

void solve2()
{
    string s, r;
    long long a, b, it;
    vector<long long> lst, ans;
    lst.resize(n+7);
    ans.resize(n+7);
    cin>>s;
    s='&'+s;
    for(int i=1; i<=n; i++)  lst[i]=0;
    for(int i=1; i<=q; i++)
    {
        cin>>r;
        if(r[0]=='t')
        {
            cin>>it;
            if(s[it]=='1') ans[it]+=i-lst[it];
            if(s[it]=='1') s[it]='0';
            else s[it]='1';
            lst[it]=i;
            continue;
        }
        cin>>a>>b;
        if(s[a]=='1') ans[a]+=i-lst[a];
        lst[a]=i;
        cout<<ans[a]<<endl;
    }
    return;
}

int main()
{
    cin>>n>>q;
    if(n<=1 && q<=1) solve1();
    else solve2();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 429 ms 4416 KB Output is correct
2 Correct 447 ms 4856 KB Output is correct
3 Correct 462 ms 5440 KB Output is correct
4 Correct 545 ms 11296 KB Output is correct
5 Correct 573 ms 11828 KB Output is correct
6 Correct 466 ms 11004 KB Output is correct
7 Correct 821 ms 11992 KB Output is correct
8 Correct 815 ms 13348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -