Submission #977863

# Submission time Handle Problem Language Result Execution time Memory
977863 2024-05-08T12:01:33 Z De3b0o Street Lamps (APIO19_street_lamps) C++14
20 / 100
106 ms 9560 KB
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define in insert
#define pb push_back
#define ppb pop_back()
#define d3 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define cans cout << ans << "\n";
#define yes cout << "Yes" << "\n";
#define no cout << "No" << "\n";
#define pll pair<ll,ll>
#define lin cout << "\n";
#define sqr 340
#define mod 1000000007
#define mid ((l+r)/2)
#define lc (2*n)
#define rc (2*n+1)

using namespace std;

ll fp(ll x , ll y)
{
    if(y==0)
        return 1;
    ll z = fp(x,y/2);
    if(y&1)
        return z*z%mod*x%mod;
    else
        return z*z%mod;
}

int sqrot(ll x)
{
    int l = 0 , r = INT_MAX;
    while(l<=r)
    {
        if(mid*mid>=x)
            r=mid-1;
        else
            l=mid+1;
    }
    return r+1;
}

ll cel(ll x , ll y)
{
    return x/y + bool(x%y);
}

bool s[300009];
ll ans[300009];
ll ti[300009];

int main()
{
    d3
    ll n , q;
    cin >> n >> q;
    string s1;
    cin >> s1;
    for(int i = 0 ; n>i ; i++)
    {
        if(s1[i]=='0')
            s[i+1]=0;
        else
            s[i+1]=1;
    }
    for(int h = 1 ; q>=h ; h++)
    {
        string t;
        cin >> t;
        if(t[0]=='q')
        {
            ll a , b;
            cin >> a >> b;
            ll x = ans[a];
            if(s[a]==1)
                x+=h-ti[a];
            cout << x << "\n";
        }
        else
        {
            ll x;
            cin >> x;
            if(s[x]==1)
            {
                ans[x]+=h-ti[x];
                s[x]=0;
            }
            else
            {
                ti[x]=h;
                s[x]=1;
            }
        }
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 66 ms 3396 KB Output is correct
2 Correct 59 ms 3828 KB Output is correct
3 Correct 62 ms 4336 KB Output is correct
4 Correct 96 ms 9560 KB Output is correct
5 Correct 81 ms 9428 KB Output is correct
6 Correct 67 ms 9380 KB Output is correct
7 Correct 97 ms 5480 KB Output is correct
8 Correct 106 ms 6788 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -