Submission #251371

# Submission time Handle Problem Language Result Execution time Memory
251371 2020-07-21T04:24:42 Z jeqcho Street Lamps (APIO19_street_lamps) C++17
0 / 100
5000 ms 5388 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpi;

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

#define pb push_back
#define rsz resize
#define sz(x) int(x.size())
#define all(x) begin(x), end(x)
#define f first
#define s second

int const N=3e5+1;
int ans[N];
int n,q;
string S;

void update()
{
    F0R(i,n+1)
    {
        if(S[i]=='1')
        {
            ++ans[i];
        }
    }
}

int query(int a,int b, int t)
{
    return ans[a];
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n>>q;
    F0R(i,n+1)fill(ans,ans+n+1,0);
    cin>>S;
    string typ;
    int i,a,b;
    int t=1;
    while(q--)
    {
        cin>>typ;
        update();
        if(typ=="toggle")
        {
            cin>>i;
            --i;
            if(S[i]=='1')S[i]='0';
            else S[i]='1';
        }
        else
        {
            cin>>a>>b;
            --a; --b;
            cout<<query(a,b,t)<<'\n';
        }
        ++t;
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 189 ms 2040 KB Output is correct
2 Correct 281 ms 4856 KB Output is correct
3 Correct 4338 ms 5388 KB Output is correct
4 Execution timed out 5071 ms 1536 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -