Submission #713593

# Submission time Handle Problem Language Result Execution time Memory
713593 2023-03-22T15:12:02 Z bin9638 Street Lamps (APIO19_street_lamps) C++17
20 / 100
3 ms 720 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define pb push_back
#define N 110
#define ii pair<int,int>
#define fs first
#define sc second
#define ld double

int a[N][N],n,q;

bool check(int t,int l,int r)
{
    for(int i=l;i<=r;i++)
        if(a[i][t]==0)
        {
         //   cout<<l<<" "<<r<<" "<<t<<endl;
            return 0;
        }
    return 1;
}

int main()
{
    #ifdef SKY
    freopen("A.inp","r",stdin);
    freopen("A.out","w",stdout);
    #endif // SKY
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n>>q;
    for(int i=1;i<=n;i++)
    {
        char ch;
        cin>>ch;
        a[i][0]=ch-'0';
    }
    for(int t=1;t<=q;t++)
    {
        for(int i=1;i<=n;i++)
            a[i][t]=a[i][t-1];
        string type;
        cin>>type;
        if(type=="toggle")
        {
            int vt;
            cin>>vt;
            a[vt][t]^=1;
        }else
        {
            int l,r,res=0;
            cin>>l>>r;
            r--;
            for(int i=0;i<t;i++)
                if(check(i,l,r))
                    res++;
            cout<<res<<endl;
        }
     //   for(int i=1;i<=n;i++)cout<<a[i][t]<<" ";cout<<endl;
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 324 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 596 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 720 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 468 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 324 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Runtime error 3 ms 596 KB Execution killed with signal 11
9 Halted 0 ms 0 KB -