Submission #440511

# Submission time Handle Problem Language Result Execution time Memory
440511 2021-07-02T11:02:16 Z den_tar Street Lamps (APIO19_street_lamps) C++14
20 / 100
1 ms 332 KB
#include <bits/stdc++.h>

using namespace std;

#define fast ios_base::sync_with_stdio();cin.tie();cout.tie();
#define en cout<<endl;
#define ops cout<<"ops"<<endl;
#define line cout<<"---------------------------"<<endl;
#define fi first
#define se second

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pllll;
typedef string str;

const ll DIM = 1e2 + 7;
const ll DIMM = 5e4 + 7;
const ll DDIM = 7;
const ll INF = 1e18 + 7;
const ll X = 1e5 + 7;
const ll BS = 2e5 + 7;
const ll AS = 26 + 7;
const ll MODULO = 1e9 + 7;

ll nt,n,m,k,q;

str s,type[DIM];

ll v1[DIM],v2[DIM];

ll a[DIM],b[DIM];

ll cres;

bool f;

bool check(ll p1,ll p2){

    for(int i=p1;i<p2;i++)
     if(b[i]==0)return false;

    return true;
}

int main()
{
    fast;
    //ll x1,y1,x2,y2;

    cin>>n>>q>>s;

    for(int i=0;i<n;i++)a[i+1]=s[i]-'0';

    for(int qq=1;qq<=q;qq++){

     cin>>type[qq]>>v1[qq];


     if(type[qq]=="query"){

      cin>>v2[qq];

      cres=0;

      for(int i=1;i<=n;i++)b[i]=a[i];

      f=check(v1[qq],v2[qq]);

      if(f)cres++;

      for(int j=1;j<qq;j++){

       if(type[j]=="toggle"){

        b[v1[j]]=1-b[v1[j]];

        f=check(v1[qq],v2[qq]);
       }

       if(f)cres++;

      }

      cout<<cres<<endl;

     }

    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 332 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 332 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 332 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Runtime error 1 ms 332 KB Execution killed with signal 11
9 Halted 0 ms 0 KB -