답안 #440452

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
440452 2021-07-02T09:57:15 Z VladM 가로등 (APIO19_street_lamps) C++14
40 / 100
826 ms 7284 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<=100 && q<=100) solve1();
    else solve2();
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 304 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 296 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 435 ms 1212 KB Output is correct
2 Correct 441 ms 1260 KB Output is correct
3 Correct 458 ms 1268 KB Output is correct
4 Correct 517 ms 6188 KB Output is correct
5 Correct 582 ms 6492 KB Output is correct
6 Correct 456 ms 6044 KB Output is correct
7 Correct 808 ms 5968 KB Output is correct
8 Correct 826 ms 7284 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 304 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 296 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 435 ms 1212 KB Output is correct
9 Correct 441 ms 1260 KB Output is correct
10 Correct 458 ms 1268 KB Output is correct
11 Correct 517 ms 6188 KB Output is correct
12 Correct 582 ms 6492 KB Output is correct
13 Correct 456 ms 6044 KB Output is correct
14 Correct 808 ms 5968 KB Output is correct
15 Correct 826 ms 7284 KB Output is correct
16 Incorrect 1 ms 204 KB Output isn't correct
17 Halted 0 ms 0 KB -