답안 #655090

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
655090 2022-11-03T03:09:40 Z DeMen100ns 가로등 (APIO19_street_lamps) C++17
20 / 100
429 ms 8880 KB
/*
Author : DeMen100ns (a.k.a Vo Khac Trieu)
School : VNU-HCM High school for the Gifted
fuck you adhoc
*/

#include <bits/stdc++.h>

using namespace std;

const int N = 3e5 + 5;
const long long INF = 1e18 + 7;
const int MAXA = 1e9;
const int B = sqrt(N) + 5;

int n, q;
string s;

int last[N];
int sum[N];

inline void subtask2(){
    s = " " + s;

    for(int i = 1; i <= q; ++i){
        string type; cin >> type;
        if (type == "query"){
            int l, r; cin >> l >> r;

            int ans = sum[l];
            if (s[l] == '1'){
                ans += (i - last[l]);
            }
            cout << ans << endl;
        } else {
            int p; cin >> p;

            if (s[p] == '1'){
                sum[p] += (i - last[p]);
            }

            last[p] = i;
            s[p] ^= 1;
        }
    }
}

void solve()
{
    cin >> n >> q;
    cin >> s;
    
    subtask2();
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    // freopen("codeforces.inp","r",stdin);
    // freopen("codeforces.out","w",stdout);

    int t = 1; // cin >> t;
    while (t--)
    {
        solve();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 237 ms 1248 KB Output is correct
2 Correct 252 ms 4772 KB Output is correct
3 Correct 241 ms 5344 KB Output is correct
4 Correct 244 ms 8880 KB Output is correct
5 Correct 284 ms 8172 KB Output is correct
6 Correct 213 ms 8612 KB Output is correct
7 Correct 427 ms 7200 KB Output is correct
8 Correct 429 ms 8596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 280 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -